mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-10-14 17:54:42 +00:00
29 lines
983 B
C#
29 lines
983 B
C#
using FluentValidation;
|
|
|
|
namespace Features.Auth.Commands.UpdateProfile;
|
|
|
|
/// <summary>Validates <see cref="UpdateProfileCommand" />, mirroring the profile rules in <c>RegisterUserValidator</c>.</summary>
|
|
public class UpdateProfileValidator : AbstractValidator<UpdateProfileCommand>
|
|
{
|
|
public UpdateProfileValidator()
|
|
{
|
|
RuleFor(x => x.FirstName)
|
|
.NotEmpty()
|
|
.WithMessage("First name is required")
|
|
.MaximumLength(128)
|
|
.WithMessage("First name cannot exceed 128 characters");
|
|
|
|
RuleFor(x => x.LastName)
|
|
.NotEmpty()
|
|
.WithMessage("Last name is required")
|
|
.MaximumLength(128)
|
|
.WithMessage("Last name cannot exceed 128 characters");
|
|
|
|
RuleFor(x => x.DateOfBirth)
|
|
.NotEmpty()
|
|
.WithMessage("Date of birth is required")
|
|
.LessThan(DateTime.Today.AddYears(-19))
|
|
.WithMessage("You must be at least 19 years old");
|
|
}
|
|
}
|