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

question: How to get object state before it was transformed in Validator? #2455

Open
rantiev opened this issue Apr 5, 2024 · 0 comments
Open
Labels
type: question Questions about the usage of the library.

Comments

@rantiev
Copy link

rantiev commented Apr 5, 2024

Sometimes due to wrong object scheme we get undefined values as a result of transformation. Hence if you use IsOptional flag, you can't check was this field transformed wrong or it didn't exist in original object.

Hence there is no difference for IsOptional fields validation of undefined fields. They just skipped.

In my opinion IsOptional should skip values only if they were missing in original object. If they were transformed wrong we need to think that they didn't pass validation. (if they transformed wrong we got wrong object input - validation should fail as it checks scheme, even if transformed scheme)

I want to create my own @WasTransformedProperly() or @IsOptionaIfNotSetOriginally()
Or to check original object state in my custom validators...

Is this possible?

I see that other people are complaining about similar cases (IsOptional skipping undefined when it shouldn't) also.
What could we do with this? Any workaround, proposal or existing PRs?

@rantiev rantiev added the type: question Questions about the usage of the library. label Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Questions about the usage of the library.
Development

No branches or pull requests

1 participant