feat: add standard schema support and associated tests#2588
feat: add standard schema support and associated tests#2588GregoireBellon wants to merge 1 commit intotypestack:developfrom
Conversation
|
@braaar @NoNameProvided This would be massive if this can be supported. See discussion here nestjs/nest#14539 for possible rework? |
|
@braaar @NoNameProvided Any updates would be greatly appreciated and or appointing some new maintainers. |
|
What's left on this? Can we get this merged? |
|
Hello @niemyjski, sorry for not responding earlier, I kinda lost interest in this PR since I don't think it will ever be merged. This is not fully ready. Making class validator compliant will require adding a new API. Citing my comment on the Nest compatibility with standard schema issue :
Since nobody is currently governing the project, I don't believe that any significant change in the API will be approved. |
|
Thanks for your reply, I really like this library at this point I think I might have to fork or move to zod :( |
Description
This PR adds the support for standard schema, by copying their interface, extending the validator with it, and mapping class validator's "Validation Error" type to standard schema's "Issue".
I also wrote some tests, which are the same as the "nested validation" ones.
Since this function would be in the hot path, I tried to make it optimized, by avoiding recursion and preferring mutation to copy.
Supporting the Standard Schema interface is important, since it's blocking the adoption of it by NestJs (see related nestjs/nest/#14539)
edit: by itself, the PR in its current form would not be enough. We need to add a wrapper function, that takes a schema as input, and that outputs a validator containing the schema. Let me know if it sounds good to you.
Disclosure
I had to ignore the ESLint warning when copying the standard schema interface.
Checklist
Update index.md)develop)npm run prettier:checkpassesnpm run lint:checkpassesFixes
addresses #2577