Created
July 16, 2022 16:32
-
-
Save Klerith/c77edd9d86174aa68efbfddd21f053a2 to your computer and use it in GitHub Desktop.
Password validation - DTO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@IsString() | |
@MinLength(6) | |
@MaxLength(50) | |
@Matches( | |
/(?:(?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/, { | |
message: 'The password must have a Uppercase, lowercase letter and a number' | |
}) | |
password: string; |
Muchas gracias! 🤝
import {
IsStrongPassword,
} from 'class-validator';
Recomiendo usar este decorador para controlar la fortaleza de la password. Ajustar los parámetros.
@IsStrongPassword({
minLength: 6,
minLowercase: 1,
minUppercase: 1,
minNumbers: 1,
minSymbols: 0,
})
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bendiciones