| | | 1 | | using ArturRios.Heimdall.Shared.Messages; |
| | | 2 | | using FluentValidation; |
| | | 3 | | |
| | | 4 | | namespace ArturRios.Heimdall.Command.Input.Validation; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// The field rules for a password person, shared by every command that creates one (UC-06 path a, |
| | | 8 | | /// UC-47), so an administrator and a self-registering caller can never be held to different rules. |
| | | 9 | | /// </summary> |
| | | 10 | | public static class PersonFieldRules |
| | | 11 | | { |
| | | 12 | | public static IRuleBuilderOptions<T, string> PersonName<T>(this IRuleBuilder<T, string> rule) => |
| | 53 | 13 | | rule.NotEmpty().WithMessage(PersonMessages.NameRequired) |
| | 53 | 14 | | .MaximumLength(200).WithMessage(PersonMessages.NameTooLong); |
| | | 15 | | |
| | | 16 | | public static IRuleBuilderOptions<T, string> PersonEmail<T>(this IRuleBuilder<T, string> rule) => |
| | 53 | 17 | | rule.NotEmpty().WithMessage(PersonMessages.EmailRequired) |
| | 53 | 18 | | .EmailAddress().WithMessage(PersonMessages.EmailInvalid) |
| | 53 | 19 | | .MaximumLength(256).WithMessage(PersonMessages.EmailTooLong); |
| | | 20 | | |
| | | 21 | | public static IRuleBuilderOptions<T, string> PersonPassword<T>(this IRuleBuilder<T, string> rule) => |
| | 53 | 22 | | rule.NotEmpty().WithMessage(PersonMessages.PasswordRequired) |
| | 53 | 23 | | .MinimumLength(8).WithMessage(PersonMessages.PasswordTooShort); |
| | | 24 | | } |