class-validator
class-validator copied to clipboard
feat: make `IsOptional` conditional
Description
This is a modified copy of the old PR #196.
Checklist
- [x] the pull request title describes what this PR does (not a vague title like
Update index.md) - [x] the pull request targets the default branch of the repository (
develop) - [x] the code follows the established code style of the repository
npm run prettier:checkpassesnpm run lint:checkpasses
- [x] tests are added for the changes I made (if any source code was modified)
- [x] documentation added or updated
- [x] I have run the project locally and verified that there are no errors
Fixes
fixes #651
This is stuck for too much time.. can save a lot effort of writing custom validators which not always work..
Please merge this pr
this repo is not maintained, I ended up copying the relevant code to my project it worked great
Please rebase to review.
What is the difference to ValidateIf?
@Clashsoft this is the difference: ValidateIf - ignore all validations if condition is met IsOptional - allows a field not to be specified when condition is met. but if the field is specified (even if condition is met!): all validations will be checked!!
Please, aprove this PR! It's must needed
@NoNameProvided can we merge this one? It is very useful validator and people use different workarounds to use it. I am sure community will be thankful for this one 🙌
See my recent comment in #1721