public EmployeeValidator() { RuleFor(x => x.FirstName) .NotEmpty() .WithMessage(DefaultMessages .MustNotBeEmptyMessage("First Name")); RuleFor(x => x.LastName) .NotEmpty() .WithMessage(DefaultMessages .MustNotBeEmptyMessage("Last Name")); RuleFor(x => x.Cpf) .Must(CpfCheckDigit.IsValidCheckDigit) .WithMessage("Cpf must be in the format 00000000000 and must have a valid check digit"); RuleFor(x => x.Sector) .NotEmpty() .WithMessage(DefaultMessages .MustNotBeEmptyMessage(nameof(Employee.Sector))); RuleFor(x => x.GrossSalary) .NotEqual(0) .WithMessage(DefaultMessages .MustNotBeZeroMessage(nameof(Employee.GrossSalary))); RuleFor(x => x.AdmissionDate) .NotEmpty() .Must(x => x != DateTime.MinValue) .WithMessage("Admission date must be a valid DateTime."); }
public PaycheckEntryValidator() { RuleFor(x => x.EntryType) .IsInEnum() .WithMessage("This entry type is not valid."); RuleFor(x => x.Value) .NotEmpty() .WithMessage(DefaultMessages .MustNotBeZeroMessage(nameof(PaycheckEntry.Value))); RuleFor(x => x.Description) .NotEmpty() .WithMessage(DefaultMessages .MustNotBeEmptyMessage(nameof(PaycheckEntry.Description))); }
public PaycheckValidator() { RuleFor(x => x.Entries) .NotEmpty() .WithMessage(DefaultMessages .MustNotBeEmptyMessage(nameof(Paycheck.Entries))); RuleFor(x => x.GrossSalary) .NotEmpty() .WithMessage(DefaultMessages .MustNotBeZeroMessage("Gross Salary")); RuleFor(x => x.NetSalary) .NotEmpty() .WithMessage(DefaultMessages .MustNotBeZeroMessage("Net Salary")); }