Ejemplo n.º 1
0
 public UpdateMenuItemValidator(ISiteRules siteRules,
                                IPageRules pageRules,
                                ILanguageRules languageRules,
                                IValidator <MenuItemDetails.MenuItemLocalisation> localisationValidator)
     : base(siteRules, pageRules, languageRules, localisationValidator)
 {
 }
        public UpdateSiteDetailsValidator(ISiteRules siteRules,
                                          ILanguageRules languageRules,
                                          IValidator <UpdateSiteDetails.SiteLocalisation> localisationValidator)
        {
            _siteRules             = siteRules;
            _siteRules             = siteRules;
            _languageRules         = languageRules;
            _localisationValidator = localisationValidator;

            RuleFor(c => c.Url)
            .NotEmpty().WithMessage("Site url is required.")
            .Length(1, 50).WithMessage("Site url length must be between 1 and 200 characters.")
            .Must(HaveValidUrl).WithMessage("Site url is not valid. Enter only letters, numbers, underscores and hyphens with no spaces.")
            .Must(HaveUniqueUrl).WithMessage("A site with the same url already exists.");

            RuleFor(c => c.Title)
            .Length(1, 250).WithMessage("Head title cannot have more than 250 characters.")
            .When(x => !string.IsNullOrWhiteSpace(x.Title));

            RuleFor(c => c.MetaDescription)
            .Length(1, 500).WithMessage("Meta description cannot have more than 500 characters.")
            .When(x => !string.IsNullOrWhiteSpace(x.MetaDescription));

            RuleFor(c => c.MetaKeywords)
            .Length(1, 500).WithMessage("Meta keywords cannot have more than 500 characters.")
            .When(x => !string.IsNullOrWhiteSpace(x.MetaKeywords));

            RuleFor(c => c.SiteLocalisations)
            .Must(IncludeAllSupportedLanguages).WithMessage("All supported languages should be included.");

            RuleFor(c => c.SiteLocalisations)
            .SetCollectionValidator(_localisationValidator);
        }
Ejemplo n.º 3
0
 public UpdatePageDetailsValidator(IPageRules pageRules,
                                   ISiteRules siteRules,
                                   ILanguageRules languageRules,
                                   IValidator <PageLocalisation> localisationValidator)
     : base(pageRules, siteRules, languageRules, localisationValidator)
 {
 }
Ejemplo n.º 4
0
        public AddVersionValidator(ITextModuleRules textModuleRules,
                                   IModuleRules moduleRules,
                                   ISiteRules siteRules,
                                   ILanguageRules languageRules,
                                   IValidator <AddVersion.VersionLocalisation> localisationValidator)
        {
            _textModuleRules       = textModuleRules;
            _moduleRules           = moduleRules;
            _siteRules             = siteRules;
            _languageRules         = languageRules;
            _localisationValidator = localisationValidator;

            RuleFor(c => c.ModuleId)
            .NotEmpty().WithMessage("Module id is required.")
            .Must(BeAnExistingModule).WithMessage("Module does not exist.");

            RuleFor(c => c.SiteId)
            .NotEmpty().WithMessage("Site id is required.")
            .Must(BeAnExistingSite).WithMessage("Site does not exist.");

            RuleFor(c => c.Content)
            .NotEmpty().WithMessage("Content is required.");

            RuleFor(c => c.Description)
            .Length(1, 250).WithMessage("Description cannot be longer of 250 characters.")
            .When(c => !string.IsNullOrWhiteSpace(c.Description));

            RuleFor(c => c.VersionLocalisations)
            .Must(IncludeAllSupportedLanguages).WithMessage("All supported languages should be included.");

            RuleFor(c => c.VersionLocalisations)
            .SetCollectionValidator(_localisationValidator);
        }
Ejemplo n.º 5
0
        public MenuItemValidator(ISiteRules siteRules,
                                 IPageRules pageRules,
                                 ILanguageRules languageRules,
                                 IValidator <MenuItemLocalisation> localisationValidator)
            : base(siteRules)
        {
            _pageRules             = pageRules;
            _languageRules         = languageRules;
            _localisationValidator = localisationValidator;

            RuleFor(c => c.PageId)
            .NotEmpty().WithMessage("Page is required.")
            .Must(BeAnExistingPage).WithMessage("Page does not exist.")
            .When(c => c.Type == MenuItemType.Page);

            RuleFor(c => c.Link)
            .NotEmpty().WithMessage("Link is required.")
            .Length(1, 250).WithMessage("Link length must be between 1 and 250 characters.")
            .When(c => c.Type == MenuItemType.Link);

            RuleFor(c => c.Text)
            .NotEmpty().WithMessage("Text is required.")
            .Length(1, 100).WithMessage("Text length must be between 1 and 100 characters.");

            RuleFor(c => c.Title)
            .Length(1, 100).WithMessage("Title length must be between 1 and 100 characters.")
            .When(c => c.Title != string.Empty);

            RuleFor(c => c.MenuItemLocalisations)
            .Must(IncludeAllSupportedLanguages).WithMessage("All supported languages should be included.");

            RuleFor(c => c.MenuItemLocalisations)
            .SetCollectionValidator(_localisationValidator);
        }
Ejemplo n.º 6
0
        public LanguageDetailsValidator(ILanguageRules languageRules, ISiteRules siteRules)
        {
            _languageRules = languageRules;
            _siteRules     = siteRules;

            RuleFor(c => c.SiteId)
            .NotEmpty().WithMessage("Site id is required.")
            .Must(BeAnExistingSite).WithMessage("Site does not exist.");

            RuleFor(c => c.Name)
            .NotEmpty().WithMessage("Language name is required.")
            .Length(2, 100).WithMessage("Language name length must be between 2 and 100 characters.")
            .Must(HaveValidName).WithMessage("Language name is not valid. Enter only letters, numbers, underscores and hyphens.")
            .Must(HaveUniqueName).WithMessage("A language with the same name already exists.");

            RuleFor(c => c.CultureName)
            .NotEmpty().WithMessage("Culture name is required.")
            .Length(2, 100).WithMessage("Culture name length must be between 2 and 100 characters.")
            .Must(HaveValidCultureName).WithMessage("Culture name is not valid. Enter only letters and 1 hyphen.")
            .Must(HaveUniqueCultureName).WithMessage("A language with the same culture name already exists.");

            RuleFor(c => c.Url)
            .NotEmpty().WithMessage("Language url is required.")
            .Length(2, 100).WithMessage("Language url length must be between 2 and 100 characters.")
            .Must(HaveValidLanguageUrl).WithMessage("Language url is not valid. Enter only letters and 1 hyphen.")
            .Must(HaveUniqueLanguageUrl).WithMessage("A language with the same url already exists.");
        }
Ejemplo n.º 7
0
        public PageLocalisationValidator(IPageRules pageRules, ILanguageRules languageRules)
        {
            _pageRules     = pageRules;
            _languageRules = languageRules;

            RuleFor(c => c.LanguageId)
            .NotEmpty().WithMessage("Language is required.")
            .Must(BeAnExistingLanguage).WithMessage("Language does not exist.");

            RuleFor(c => c.Url)
            .Length(1, 200).WithMessage("Page url cannot have more than 200 characters.")
            .Must(HaveValidUrl).WithMessage("Page url is not valid. Enter only letters, numbers, underscores and hyphens with no spaces.")
            .When(x => !string.IsNullOrWhiteSpace(x.Url));

            RuleFor(c => c.Title)
            .Length(1, 250).WithMessage("Head title cannot have more than 250 characters.")
            .When(x => !string.IsNullOrWhiteSpace(x.Title));

            RuleFor(c => c.MetaDescription)
            .Length(1, 500).WithMessage("Meta description cannot have more than 500 characters.")
            .When(x => !string.IsNullOrWhiteSpace(x.MetaDescription));

            RuleFor(c => c.MetaKeywords)
            .Length(1, 500).WithMessage("Meta keywords cannot have more than 500 characters.")
            .When(x => !string.IsNullOrWhiteSpace(x.MetaKeywords));
        }
Ejemplo n.º 8
0
 public LanguageController(IDispatcher dispatcher,
                           ILanguageRules languageRules,
                           IContextService contextService)
     : base(contextService)
 {
     _dispatcher    = dispatcher;
     _languageRules = languageRules;
 }
Ejemplo n.º 9
0
        public CreateLanguageValidator(ILanguageRules languageRules, ISiteRules siteRules)
            : base(languageRules, siteRules)
        {
            _languageRules = languageRules;

            RuleFor(c => c.Id)
            .Must(HaveUniqueId).WithMessage("A language with the same id already exists.")
            .When(x => x.Id != Guid.Empty);
        }
Ejemplo n.º 10
0
 public AddMenuItemValidator(ISiteRules siteRules,
                             IPageRules pageRules,
                             ILanguageRules languageRules,
                             IValidator <MenuItemDetails.MenuItemLocalisation> localisationValidator)
     : base(siteRules, pageRules, languageRules, localisationValidator)
 {
     RuleFor(c => c.MenuItemId)
     .NotEmpty().WithMessage("Menu item id is required.");
 }
Ejemplo n.º 11
0
        public CreateLanguageValidator(ILanguageRules languageRules, ISiteRules siteRules)
            : base(languageRules, siteRules)
        {
            _languageRules = languageRules;

            RuleFor(c => c.Id)
            .NotEmpty().WithMessage("Id is required.")
            .Must(HaveUniqueId).WithMessage("A language with the same id already exists.");
        }
Ejemplo n.º 12
0
 public LanguageController(ILanguageFacade languageFacade,
                           ICommandSender commandSender,
                           ILanguageRules languageRules,
                           IContextService contextService)
     : base(contextService)
 {
     _languageFacade = languageFacade;
     _commandSender  = commandSender;
     _languageRules  = languageRules;
 }
Ejemplo n.º 13
0
 public LanguageController(ICommandSender commandSender,
                           IQueryDispatcher queryDispatcher,
                           ILanguageRules languageRules,
                           IContextService contextService)
     : base(contextService)
 {
     _commandSender   = commandSender;
     _queryDispatcher = queryDispatcher;
     _languageRules   = languageRules;
 }
        public VersionLocalisationValidator(ILanguageRules languageRules)
        {
            _languageRules = languageRules;

            RuleFor(c => c.LanguageId)
            .NotEmpty().WithMessage("Language is required.")
            .Must(BeAnExistingLanguage).WithMessage("Language does not exist.");

            RuleFor(c => c.Content)
            .Length(1, 251).WithMessage("Content cannot have more than 250 characters.")
            .When(x => !string.IsNullOrWhiteSpace(x.Content));
        }
Ejemplo n.º 15
0
        public CreatePageValidator(IPageRules pageRules,
                                   ISiteRules siteRules,
                                   ILanguageRules languageRules,
                                   IValidator <PageLocalisation> localisationValidator)
            : base(pageRules, siteRules, languageRules, localisationValidator)
        {
            _pageRules = pageRules;

            RuleFor(c => c.Id)
            .Must(HaveUniqueId).WithMessage("A page with the same id already exists.")
            .When(x => x.Id != Guid.Empty);
        }
Ejemplo n.º 16
0
        public CreatePageValidator(IPageRules pageRules,
                                   ISiteRules siteRules,
                                   ILanguageRules languageRules,
                                   IValidator <PageLocalisation> localisationValidator)
            : base(pageRules, siteRules, languageRules, localisationValidator)
        {
            _pageRules = pageRules;

            RuleFor(c => c.Id)
            .NotEmpty().WithMessage("Id is required.")
            .Must(HaveUniqueId).WithMessage("A page with the same id already exists.");
        }
Ejemplo n.º 17
0
        public PageModuleLocalisationValidator(IPageRules pageRules, ILanguageRules languageRules)
        {
            _pageRules     = pageRules;
            _languageRules = languageRules;

            RuleFor(c => c.LanguageId)
            .NotEmpty().WithMessage("Language is required.")
            .Must(BeAnExistingLanguage).WithMessage("Language does not exist.");

            RuleFor(c => c.Title)
            .Length(1, 250).WithMessage("Title cannot have more than 250 characters.")
            .When(x => !string.IsNullOrWhiteSpace(x.Title));
        }
Ejemplo n.º 18
0
        public MenuItemLocalisationValidator(ILanguageRules languageRules)
        {
            _languageRules = languageRules;

            RuleFor(c => c.LanguageId)
            .NotEmpty().WithMessage("Language is required.")
            .Must(BeAnExistingLanguage).WithMessage("Language does not exist.");

            RuleFor(c => c.Text)
            .Length(1, 100).WithMessage("Text length must be between 1 and 100 characters.")
            .When(c => c.Text != string.Empty);

            RuleFor(c => c.Title)
            .Length(1, 100).WithMessage("Title length must be between 1 and 100 characters.")
            .When(c => c.Title != string.Empty);
        }
Ejemplo n.º 19
0
        public PageDetailsValidator(IPageRules pageRules,
                                    ISiteRules siteRules,
                                    ILanguageRules languageRules,
                                    IValidator <PageLocalisation> localisationValidator)
            : base(siteRules)
        {
            _pageRules     = pageRules;
            _languageRules = languageRules;

            RuleFor(c => c.Name)
            .NotEmpty().WithMessage("Page name is required.")
            .Length(1, 100).WithMessage("Page name length must be between 1 and 100 characters.")
            .Must(HaveValidName).WithMessage("Page name is not valid. Enter only letters, numbers, underscores and hyphens.")
            .Must(HaveUniqueName).WithMessage("A page with the same name already exists.");

            RuleFor(c => c.Url)
            .NotEmpty().WithMessage("Page url is required.")
            .Length(1, 200).WithMessage("Page url length must be between 1 and 200 characters.")
            .Must(HaveValidUrl).WithMessage("Page url is not valid. Enter only letters, numbers, slashes, underscores and hyphens with no spaces.")
            .Must(NotBeReserved).WithMessage("Page url is reserved.")
            .Must(HaveUniqueSlug).WithMessage("A page with the same url already exists.");

            RuleFor(c => c.Title)
            .Length(1, 250).WithMessage("Head title cannot have more than 250 characters.")
            .When(x => !string.IsNullOrWhiteSpace(x.Title));

            RuleFor(c => c.MetaDescription)
            .Length(1, 500).WithMessage("Meta description cannot have more than 500 characters.")
            .When(x => !string.IsNullOrWhiteSpace(x.MetaDescription));

            RuleFor(c => c.MetaKeywords)
            .Length(1, 500).WithMessage("Meta keywords cannot have more than 500 characters.")
            .When(x => !string.IsNullOrWhiteSpace(x.MetaKeywords));

            RuleFor(c => c.PageLocalisations)
            .Must(IncludeAllSupportedLanguages).WithMessage("All supported languages should be included.");

            RuleFor(c => c.PageLocalisations)
            .Must(IncludeUniqueSlugs).WithMessage("A page with the same localised slug already exists.");

            RuleFor(c => c.PageLocalisations)
            .SetCollectionValidator(localisationValidator);
        }
Ejemplo n.º 20
0
        public SiteLocalisationValidator(ILanguageRules languageRules)
        {
            _languageRules = languageRules;

            RuleFor(c => c.LanguageId)
            .NotEmpty().WithMessage("Language is required.")
            .Must(BeAnExistingLanguage).WithMessage("Language does not exist.");

            RuleFor(c => c.Title)
            .Length(1, 250).WithMessage("Title cannot have more than 250 characters.")
            .When(x => !string.IsNullOrWhiteSpace(x.Title));

            RuleFor(c => c.MetaDescription)
            .Length(1, 500).WithMessage("Meta description cannot have more than 500 characters.")
            .When(x => !string.IsNullOrWhiteSpace(x.MetaDescription));

            RuleFor(c => c.MetaKeywords)
            .Length(1, 500).WithMessage("Meta keywords cannot have more than 500 characters.")
            .When(x => !string.IsNullOrWhiteSpace(x.MetaKeywords));
        }
 public UpdateLanguageDetailsValidator(ILanguageRules languageRules, ISiteRules siteRules)
     : base(languageRules, siteRules)
 {
 }