-
-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
Compatibility with standard-schema #14539
Comments
Notably, there is an issue open on class-validator side around this topic as well: |
I like the ideia but I think this should start as a 3rd-party lib to see community's adoption |
I guess there's nothing we can do until class-validator supports the standard schema too (to avoid breaking changes) |
Unfortunately, the class-validator isn't updated much anymore。typestack/class-validator#1775 |
@0x0bit well |
But he didn't spend any more time in the repository; the latest update was only a month ago. |
Would be nice to get standard-schema across the finish line and some resources added to class-validator. PR: typestack/class-validator#2588 |
I initiated a PR for class-validator to support the Standard Schema, and it led me to think that NestJs should not wait for it to be merged before adding support for standard-schema. Standard Schema assumes that the validator is closely tied to the schema it uses to validate a DTO, and that a DTO can be a standard JavaScript object. Class-validator's validator stores all validation constraints in a singleton context called "ValidationMetadata" and it relies on the DTO's constructor to identify the validation constraints related to the DTO. This means a DTO must be an instance of a class. This difference in philosophy means that class-validator will need additional APIs to support Standard Schema's approach. I think that building a new Validation Pipe, or adapting the current pipe to support standard-schema would be easier to maintain and faster to implement (especially since class-validator's repository does not seem not very active). The nest-zod package basically contains all the logic we need; we just need to replace "zod" with "standard schema". |
Thanks for your pr! I think it would be extremely beneficial to be apart of the core library. I think new maintainers is key and simplifying the library possibly for easier maintenance and scope. |
Absolutely!!! |
Is there an existing issue that is already proposing this?
Is your feature request related to a problem? Please describe it
There are numerous schema validators out there. This has spawned an ecosystem around NestJS with various integrations such as nestjs-valibot and many others.
Describe the solution you'd like
NestJS could support stanadard-schema which recently hit 1.0.0:
With that a commonly shared
ValidationPipe
could be offered directly from the framework instead of copy/pasting the integrations from the docs site.Teachability, documentation, adoption, migration strategy
Guide on how to accept Standard Schema: https://standardschema.dev/#how-do-i-accept-standard-schemas-in-my-library
ValidationPipe
that is compatible with standard-schemaValidationPipe
can be utilised with different schema librariesWhat is the motivation / use case for changing the behavior?
I think it makes NestJS more future-proof with any future schema/validation library that might come
The text was updated successfully, but these errors were encountered: