| | | 1 | | using ArturRios.Heimdall.Shared.Messages; |
| | | 2 | | using FluentValidation; |
| | | 3 | | |
| | | 4 | | namespace ArturRios.Heimdall.Command.Input.Validation; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Shape validation for <see cref="ResetPasswordCommand" /> (UC-13, AF-13d). Whether the token |
| | | 8 | | /// exists, has expired, or has been used is the handler's business (AF-13a…AF-13c). |
| | | 9 | | /// </summary> |
| | | 10 | | /// <remarks> |
| | | 11 | | /// The minimum length is the one UC-06 applies when a person is created: a reset must not be a |
| | | 12 | | /// way around the floor that person creation enforces. No maximum is imposed — the password is |
| | | 13 | | /// hashed, never stored — and no composition rules are added, since the specification defines |
| | | 14 | | /// none. |
| | | 15 | | /// </remarks> |
| | | 16 | | public class ResetPasswordCommandValidator : AbstractValidator<ResetPasswordCommand> |
| | | 17 | | { |
| | 37 | 18 | | public ResetPasswordCommandValidator() |
| | | 19 | | { |
| | 37 | 20 | | RuleFor(command => command.Token) |
| | 37 | 21 | | .NotEmpty().WithMessage(AuthMessages.TokenRequired); |
| | | 22 | | |
| | 37 | 23 | | RuleFor(command => command.NewPassword) |
| | 37 | 24 | | .NotEmpty().WithMessage(AuthMessages.PasswordRequired) |
| | 37 | 25 | | .MinimumLength(8).WithMessage(AuthMessages.PasswordTooShort); |
| | 37 | 26 | | } |
| | | 27 | | } |