DEV Community

Discussion on: Schema based validation using express-validator in Node.js

Collapse
 
kostyatretyak profile image
Костя Третяк • Edited

It is even better to use a schema of OpenAPI documentation for validation. It is best to use decorators to write validation schema:

class LoginData {
  @Column({ [IS_REQUIRED]: true, pattern: config.emailPattern.source })
  email: string;
  @Column({ [IS_REQUIRED]: true, minLength: config.minLengthPassword, maxLength: config.maxLengthPassword })
  password: string;
}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
jayeshchoudhary profile image
Jayesh Choudhary • Edited

Great ... didn't know about this, Thanks :)