Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Greedy Validation for Arrays #1229

Open
bradleat opened this issue Aug 17, 2024 · 1 comment
Open

Greedy Validation for Arrays #1229

bradleat opened this issue Aug 17, 2024 · 1 comment
Assignees
Labels
invalid This doesn't seem right question Further information is requested wontfix This will not be worked on

Comments

@bradleat
Copy link

#1211

Following up from there. It would be nice if we had greedy validation for arrays.

For instance, I have an array with the following entries:

const array = [1,2,3,4,5];

However the type is:

type Example = 1 | 2;

Some function to make that:

const validatedArray = [1, 2];
@samchon samchon added invalid This doesn't seem right question Further information is requested labels Aug 20, 2024
@samchon
Copy link
Owner

samchon commented Aug 20, 2024

This idea cannot be accomplished, because number of cases for the greedy validation is infinite.

Your example case seems simple and easy, but if the type is extended to complicated types like union cases with deep nested object and array types, no way to implement it. About the truncation, only typia.misc.prune() like function, which performing the truncation based on the current value is satisfyinig the target type, can be come true.

@samchon samchon self-assigned this Aug 20, 2024
@samchon samchon added the wontfix This will not be worked on label Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right question Further information is requested wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants