| | | 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="UpdateScopePermissionCommand" /> (UC-33 main flow step 2). |
| | | 8 | | /// The messages are UC-31's: the two use cases reject the same shapes, and UC-33 defines no |
| | | 9 | | /// alternative flow of its own for invalid input. Permission existence and actor authorization |
| | | 10 | | /// are enforced by the handler. A <c>null</c> description is valid: FluentValidation's |
| | | 11 | | /// <c>MaximumLength</c> rule skips <c>null</c> arguments, so only a non-null overlong description |
| | | 12 | | /// is rejected. |
| | | 13 | | /// </summary> |
| | | 14 | | public class UpdateScopePermissionCommandValidator : AbstractValidator<UpdateScopePermissionCommand> |
| | | 15 | | { |
| | 16 | 16 | | public UpdateScopePermissionCommandValidator() |
| | | 17 | | { |
| | 16 | 18 | | RuleFor(command => command.Name) |
| | 16 | 19 | | .NotEmpty().WithMessage(ScopePermissionMessages.NameRequired) |
| | 16 | 20 | | .MaximumLength(200).WithMessage(ScopePermissionMessages.NameTooLong); |
| | | 21 | | |
| | 16 | 22 | | RuleFor(command => command.Description) |
| | 16 | 23 | | .MaximumLength(500).WithMessage(ScopePermissionMessages.DescriptionTooLong); |
| | 16 | 24 | | } |
| | | 25 | | } |