| | | 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="LoginCommand" /> (UC-11 AF-11f, NFR-10). Whether the |
| | | 8 | | /// credentials are <em>correct</em> is the handler's business, and every wrong answer there is a |
| | | 9 | | /// single 401 (AF-11a…AF-11e). |
| | | 10 | | /// </summary> |
| | | 11 | | /// <remarks> |
| | | 12 | | /// Deliberately no minimum password length, unlike the validators that guard person creation: at |
| | | 13 | | /// login a short password is a failed attempt, not a malformed request, and answering 400 to it |
| | | 14 | | /// would tell a caller their guess was too short to be anyone's password. |
| | | 15 | | /// </remarks> |
| | | 16 | | public class LoginCommandValidator : AbstractValidator<LoginCommand> |
| | | 17 | | { |
| | 111 | 18 | | public LoginCommandValidator() |
| | | 19 | | { |
| | 111 | 20 | | RuleFor(command => command.Email) |
| | 111 | 21 | | .NotEmpty().WithMessage(AuthMessages.EmailRequired) |
| | 111 | 22 | | .EmailAddress().WithMessage(AuthMessages.EmailInvalid); |
| | | 23 | | |
| | 111 | 24 | | RuleFor(command => command.Password) |
| | 111 | 25 | | .NotEmpty().WithMessage(AuthMessages.PasswordRequired); |
| | 111 | 26 | | } |
| | | 27 | | } |