class-validator icon indicating copy to clipboard operation
class-validator copied to clipboard

feat: make `IsOptional` conditional

Open ruscon opened this issue 5 years ago • 9 comments

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:check passes
    • npm run lint:check passes
  • [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

ruscon avatar Aug 10 '20 12:08 ruscon

This is stuck for too much time.. can save a lot effort of writing custom validators which not always work..

Please merge this pr

aqemi avatar Jun 30 '22 13:06 aqemi

this repo is not maintained, I ended up copying the relevant code to my project it worked great

Please rebase to review.

NoNameProvided avatar Nov 20 '22 19:11 NoNameProvided

What is the difference to ValidateIf?

Clashsoft avatar Apr 13 '23 11:04 Clashsoft

@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

joaofranciscoguarda avatar Oct 17 '23 20:10 joaofranciscoguarda

@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 🙌

armansujoyan avatar Nov 30 '23 13:11 armansujoyan

See my recent comment in #1721

braaar avatar Dec 15 '23 05:12 braaar