title: Password confirmation in TypeScript with `class-validator`
body: <p>Today, I am trying to figure out how to validate a Sign Up form in the backend side (NestJS) of the app. I am just wondering if exists a way to validate <code>password</code> and <code>passwordConfirm</code> matching, using <code>class-validator</code> package to build up a custom validator or exploit provided ones. I am thinking about a class validator, not a field one.</p>
  
  <pre><code>// Maybe validator here
  export class SignUpDto {
      @IsString()
      @MinLength(4)
      @MaxLength(20)
      username: string;
  
      @IsString()
      @MinLength(4)
      @MaxLength(20)
      @Matches(/((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/, {message: 'password too weak'})
      password: string;
  
      @IsString()
      @MinLength(4)
      @MaxLength(20)
      passwordConfirm: string;
  }
  </code></pre>
  
  <p>What do you suggest?</p>