Password Validator in Fluent Validation

Viewed 1534

How can I validate Password using Fluent Validation? for example, using data annotation we can put this attribute [Password] for password property, how to get the same result but using fluent validation???

when I type in the box of password it shows black circles when I use data annotation, how to do the same but using fluent validation?

1 Answers

You can use the Equal Validator to check if the property is equal to the value of another property e.g.

RuleFor(customer => customer.Password)
    .Equal(customer => customer.PasswordConfirmation);

Equal Validator Documentation

To create a field for password entry where the input is hidden use type="password" e.g.

<input type="password" @asp-for="Model.Password">

Input field documentation

Related