using FluentValidation; using SeaHaven.Services.DTOs; namespace SeaHaven.Services.Validation { public interface ICreateAccountValidation : IValidator { } public class CreateAccountValidation : AbstractValidator, ICreateAccountValidation { public CreateAccountValidation() { RuleFor(x => x.Name) .NotEmpty().WithMessage("Account name is required") .MaximumLength(200).WithMessage("Account name cannot exceed 200 characters"); RuleFor(x => x.Email) .EmailAddress().WithMessage("Invalid email address") .When(x => !string.IsNullOrEmpty(x.Email)); RuleFor(x => x.Phone) .MaximumLength(20).WithMessage("Phone number cannot exceed 20 characters") .When(x => !string.IsNullOrEmpty(x.Phone)); RuleFor(x => x.Website) .MaximumLength(200).WithMessage("Website cannot exceed 200 characters") .When(x => !string.IsNullOrEmpty(x.Website)); } } public interface IUpdateAccountValidation : IValidator { } public class UpdateAccountValidation : AbstractValidator, IUpdateAccountValidation { public UpdateAccountValidation() { RuleFor(x => x.Name) .MaximumLength(200).WithMessage("Account name cannot exceed 200 characters") .When(x => !string.IsNullOrEmpty(x.Name)); RuleFor(x => x.Email) .EmailAddress().WithMessage("Invalid email address") .When(x => !string.IsNullOrEmpty(x.Email)); RuleFor(x => x.Phone) .MaximumLength(20).WithMessage("Phone number cannot exceed 20 characters") .When(x => !string.IsNullOrEmpty(x.Phone)); RuleFor(x => x.Website) .MaximumLength(200).WithMessage("Website cannot exceed 200 characters") .When(x => !string.IsNullOrEmpty(x.Website)); } } }