classlib/ExpenseTracker.Application/Authentication/Commands/RegisterWithEmail/RegisterWithEmailValidator.cs
2024-08-07 21:12:02 +03:00

17 lines
518 B
C#

using FluentValidation;
namespace ExpenseTracker.Application.Authentication.Commands.RegisterWithEmail;
public class RegisterWithEmailCommandValidator : AbstractValidator<RegisterWithEmailCommand>
{
public RegisterWithEmailCommandValidator()
{
// https://regexr.com/2ri2c
RuleFor(v => v.Email)
.NotEmpty()
.WithMessage("Email address is required.")
.Matches(@"\b[\w\.-]+@[\w\.-]+\.\w{2,4}\b")
.WithMessage("Email address is invalid.");
}
}