| 123456789101112131415161718192021222324252627282930313233 |
- using Quadarax.Application.QLiberace.Base.Repositories;
- using Quadarax.Foundation.Core.Value;
- namespace Quadarax.Application.QLiberace.Customer.Dtos.Validators
- {
- public class CustomerValidator : Validator<CustomerWDto>
- {
- protected override void OnValidate(CustomerWDto validatingObject, ValidatorContext context)
- {
- CheckIfEmpty("Name", validatingObject.Name, ValidationResult.ValidationSeverityEnum.Error);
- CheckIfStringMaxLengthOverflow("Name", validatingObject.Name, 100,
- ValidationResult.ValidationSeverityEnum.Error);
- CheckIfEmpty("TaxCountryCode", validatingObject.TaxCountryCode, ValidationResult.ValidationSeverityEnum.Error);
- CheckIfStringMaxLengthOverflow("TaxCountryCode", validatingObject.TaxCountryCode, 5,
- ValidationResult.ValidationSeverityEnum.Error);
- if (!string.IsNullOrEmpty(validatingObject.TaxCountryCode))
- {
- var rcurr = context.GetValue<RepoCountry>("RepoCountry");
- CheckIfNull("TaxCountryCode",rcurr.GetByCode(validatingObject.TaxCountryCode), ValidationResult.ValidationSeverityEnum.Error, $"Customer TaxCountryCode not match country code '{validatingObject.TaxCountryCode}' with enumeration");
- }
-
- CheckIfStringMaxLengthOverflow("TaxNumber", validatingObject.TaxNumber, 20,
- ValidationResult.ValidationSeverityEnum.Error);
- CheckIfStringMaxLengthOverflow("VatNumber", validatingObject.VatNumber, 20,
- ValidationResult.ValidationSeverityEnum.Error);
- }
- }
- }
|