Exemple #1
0
        public CreateTemplateValidator(ITemplateRules templateRules) : base(templateRules)
        {
            _templateRules = templateRules;

            RuleFor(c => c.Id)
            .NotEmpty().WithMessage("Id is required.")
            .Must(HaveUniqueId).WithMessage("A template with the same id already exists.");
        }
        public CreateTemplateValidator(ITemplateRules templateRules) : base(templateRules)
        {
            _templateRules = templateRules;

            RuleFor(c => c.Id)
            .Must(HaveUniqueId).WithMessage("A template with the same id already exists.")
            .When(x => x.Id != Guid.Empty);
        }
        public TemplateDetailsValidator(ITemplateRules templateRules)
        {
            _templateRules = templateRules;

            RuleFor(c => c.Name)
            .NotEmpty().WithMessage("Template name is required.")
            .Length(1, 100).WithMessage("Template name length must be between 1 and 100 characters.")
            .Must(HaveUniqueName).WithMessage("A template with the same name already exists.");

            RuleFor(c => c.Description)
            .Length(1, 250).WithMessage("Culture name length must be between 1 and 250 characters.")
            .When(c => !string.IsNullOrWhiteSpace(c.Description));

            RuleFor(c => c.ViewName)
            .NotEmpty().WithMessage("Template view name is required.")
            .Length(1, 250).WithMessage("Template view name length must be between 1 and 250 characters.")
            .Must(HaveValidTemplateViewName).WithMessage("Template url is not valid. Enter only letters and 1 hyphen.")
            .Must(HaveUniqueTemplateViewName).WithMessage("A template with the same url already exists.");
        }
 public UpdateTemplateDetailsValidator(ITemplateRules templateRules, IThemeRules themeRules)
     : base(templateRules, themeRules)
 {
 }