dev-plusplus / coding-docs

4 stars 2 forks source link

Class Validator + Yup #79

Open alacret opened 2 years ago

sciretta commented 2 years ago

@alacret

Class-Validator Yup
Advantages
  • Most declarative (my opinion)
  • Phone number validation by default with @IsPhoneNumber(region: string)
  • Support with react-hook-forms
  • Used by NestJS
  • More popular
  • Lighter than class-validator (222kb vs 60kb)
Disadvantages
  • Set experimentalDecorators as true on tsconfig
  • For phone numbers you need to pass a regex, which makes the code look dirtier
How it looks (with RHF) image image