using FluentValidation; namespace AutobusApi.Application.Companies.Commands.UpdateCompany; public class UpdateCompanyCommandValidator : AbstractValidator { public UpdateCompanyCommandValidator() { RuleFor(v => v.Id).GreaterThan(0); RuleFor(v => v.Name).MinimumLength(2).MaximumLength(64); RuleFor(v => v.LegalAddress).MinimumLength(2).MaximumLength(256); RuleFor(v => v.ContactPhoneNumber) .NotEmpty().WithMessage("Phone number is required.") .Matches(@"^\s*(?:\+?(\d{1,3}))?([-. (]*(\d{3})[-. )]*)?((\d{3})[-. ]*(\d{2,4})(?:[-.x ]*(\d+))?)\s*$").WithMessage("Phone number is invalid."); RuleFor(v => v.ContactEmail) .NotEmpty().WithMessage("Email address is required.") .Matches(@"\b[\w\.-]+@[\w\.-]+\.\w{2,4}\b").WithMessage("Email address is invalid."); } }