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 #1211

Closed
mysuf opened this issue Aug 8, 2024 · 0 comments
Closed

Greedy validation #1211

mysuf opened this issue Aug 8, 2024 · 0 comments

Comments

@mysuf
Copy link

mysuf commented Aug 8, 2024

I have huge nested tree type definition and I'm wondering about few things:

  1. when I call createValidate on top most data type that holds other types, F.e.:
interface Bar { "value": string; }
interface Foo { "foo": Bar; }

const validateBar = typia.createValidate<Bar>();
const validateFoo = typia.createValidate<Foo>();

Does validateFoo reuse the validateBar function internally? Otherwise it would be a lot of duplicated validator code.

  1. Does prune works also on array items and optional invalid fields? Docs says only superfluous properties so probably not? F.e:
interface Foo {
  value?: string;
  arr: Array<string & tags.MinItems<1>>;
}

const res: typia.IValidation<Foo> = typia.misc.validatePrune<Foo>({ value: 1, arr: ["a", 2] });

/** Expected:
 * 1 is not a string, but it is optional so it fallbacks to undefined -> should log warning/error
 * 2 is not a string so it is removed. It still passes the MinItems validation -> should log warning/error
 * /
console.log(res.data); // { arr: ["a"] }

I need basically greedy validator that returns the maximum possible while maintaining validity, together with warnings/errors. Any tips appreciated. Thanks

@mysuf mysuf changed the title Lazy validation Greedy validation Aug 8, 2024
@mysuf mysuf closed this as completed Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant