Skip to content

Password Rules ​

Password rules validate common password composition requirements. They only inspect the submitted value; they do not hash passwords, compare stored passwords, or enforce account-specific password history.

Use PasswordSecure for the normal strict requirement, or combine smaller password rules when the application controls the exact password policy.

Password ​

Adds several password requirements at once. By default it requires letters, mixed casing, numbers, and symbols; pass false for a requirement to skip that part.

csharp
[PasswordLetters]
[PasswordMixed]
[PasswordNumbers]
[PasswordSymbols]
csharp
RuleFor(x => x.Password)
    .Password();

PasswordLetters ​

Requires the password to contain at least one letter.

csharp
[PasswordLetters]
csharp
RuleFor(x => x.Password)
    .PasswordLetters();

PasswordMixed ​

Requires the password to contain at least one lowercase and one uppercase letter.

csharp
[PasswordMixed]
csharp
RuleFor(x => x.Password)
    .PasswordMixed();

PasswordNumbers ​

Requires the password to contain at least one number.

csharp
[PasswordNumbers]
csharp
RuleFor(x => x.Password)
    .PasswordNumbers();

PasswordSymbols ​

Requires the password to contain at least one punctuation or symbol character.

csharp
[PasswordSymbols]
csharp
RuleFor(x => x.Password)
    .PasswordSymbols();

PasswordSecure ​

Requires the password to contain mixed-case letters, at least one number, and at least one symbol.

csharp
[PasswordSecure]
csharp
RuleFor(x => x.Password)
    .PasswordSecure();

All packages are released under the MIT License.