Beispiel #1
0
        internal static void AddCommonRules(this AbstractValidator <VacancyQuestionsViewModel> validator)
        {
            validator.RuleFor(x => x.FirstQuestion)
            .Length(0, 4000)
            .WithMessage(VacancyViewModelMessages.FirstQuestion.TooLongErrorText)
            .Matches(VacancyViewModelMessages.FirstQuestion.WhiteListTextRegularExpression)
            .WithMessage(VacancyViewModelMessages.FirstQuestion.WhiteListInvalidCharacterErrorText)
            .Must(Validators.Common.BeAValidFreeText)
            .WithMessage(VacancyViewModelMessages.FirstQuestion.WhiteListInvalidTagErrorText)
            .When(x => Common.IsNotEmpty(x.FirstQuestion));

            validator.RuleFor(x => x.SecondQuestion)
            .Length(0, 4000)
            .WithMessage(VacancyViewModelMessages.SecondQuestion.TooLongErrorText)
            .Matches(VacancyViewModelMessages.SecondQuestion.WhiteListTextRegularExpression)
            .WithMessage(VacancyViewModelMessages.SecondQuestion.WhiteListInvalidCharacterErrorText)
            .Must(Validators.Common.BeAValidFreeText)
            .WithMessage(VacancyViewModelMessages.SecondQuestion.WhiteListInvalidTagErrorText)
            .When(x => Common.IsNotEmpty(x.SecondQuestion));

            validator.RuleFor(x => x.FirstQuestionComment)
            .Matches(VacancyViewModelMessages.FirstQuestion.WhiteListTextRegularExpression)
            .WithMessage(VacancyViewModelMessages.FirstQuestion.WhiteListInvalidCharacterErrorText);

            validator.RuleFor(x => x.SecondQuestionComment)
            .Matches(VacancyViewModelMessages.SecondQuestion.WhiteListTextRegularExpression)
            .WithMessage(VacancyViewModelMessages.SecondQuestion.WhiteListInvalidCharacterErrorText);
        }
Beispiel #2
0
        internal static void AddCommonRules(this AbstractValidator <TrainingDetailsViewModel> validator)
        {
            validator.RuleFor(m => m.StandardIdComment)
            .Matches(VacancyViewModelMessages.Comment.WhiteListRegularExpression)
            .WithMessage(VacancyViewModelMessages.Comment.WhiteListErrorText);

            validator.RuleFor(m => m.ApprenticeshipLevelComment)
            .Matches(VacancyViewModelMessages.Comment.WhiteListRegularExpression)
            .WithMessage(VacancyViewModelMessages.Comment.WhiteListErrorText);

            validator.RuleFor(m => m.FrameworkCodeNameComment)
            .Matches(VacancyViewModelMessages.Comment.WhiteListRegularExpression)
            .WithMessage(VacancyViewModelMessages.Comment.WhiteListErrorText);

            validator.RuleFor(m => m.SectorCodeNameComment)
            .Matches(VacancyViewModelMessages.Comment.WhiteListRegularExpression)
            .WithMessage(VacancyViewModelMessages.Comment.WhiteListErrorText);

            validator.RuleFor(m => m.TrainingProvided)
            .Matches(VacancyViewModelMessages.TrainingProvidedMessages.WhiteListHtmlRegularExpression)
            .WithMessage(VacancyViewModelMessages.TrainingProvidedMessages.WhiteListInvalidCharacterErrorText)
            .Must(Common.BeAValidFreeText)
            .WithMessage(VacancyViewModelMessages.TrainingProvidedMessages.WhiteListInvalidTagErrorText)
            .When(x => Common.IsNotEmpty(x.TrainingProvided));

            validator.RuleFor(m => m.TrainingProvidedComment)
            .Matches(VacancyViewModelMessages.Comment.WhiteListRegularExpression)
            .WithMessage(VacancyViewModelMessages.Comment.WhiteListErrorText);

            validator.RuleFor(m => m.ContactName)
            .Length(0, 100)
            .WithMessage(VacancyViewModelMessages.ContactNameMessages.TooLongErrorText)
            .Matches(VacancyViewModelMessages.ContactNameMessages.WhiteListRegularExpression)
            .WithMessage(VacancyViewModelMessages.ContactNameMessages.WhiteListErrorText)
            .When(x => x.VacancySource == VacancySource.Raa);

            validator.RuleFor(m => m.ContactName)
            .Matches(VacancyViewModelMessages.ContactNameMessages.FreeTextRegularExpression)
            .WithMessage(VacancyViewModelMessages.ContactNameMessages.WhiteListErrorText)
            .When(x => x.VacancySource != VacancySource.Raa && Common.IsNotEmpty(x.ContactName));

            validator.RuleFor(x => x.ContactNumber)
            .Length(8, 16)
            .WithMessage(VacancyViewModelMessages.ContactNumberMessages.LengthErrorText)
            .Matches(VacancyViewModelMessages.ContactNumberMessages.WhiteListRegularExpression)
            .WithMessage(VacancyViewModelMessages.ContactNumberMessages.WhiteListErrorText);

            validator.RuleFor(m => m.ContactEmail)
            .Length(0, 100)
            .WithMessage(VacancyViewModelMessages.ContactEmailMessages.TooLongErrorText)
            .Matches(VacancyViewModelMessages.ContactEmailMessages.WhiteListRegularExpression)
            .WithMessage(VacancyViewModelMessages.ContactEmailMessages.WhiteListErrorText);

            validator.RuleFor(m => m.ContactDetailsComment)
            .Matches(VacancyViewModelMessages.Comment.WhiteListRegularExpression)
            .WithMessage(VacancyViewModelMessages.Comment.WhiteListErrorText);
        }
        internal static void AddCommonRules(this AbstractValidator <VacancyRequirementsProspectsViewModel> validator)
        {
            validator.RuleFor(x => x.DesiredSkills)
            .Matches(VacancyViewModelMessages.DesiredSkills.WhiteListHtmlRegularExpression)
            .WithMessage(VacancyViewModelMessages.DesiredSkills.WhiteListInvalidCharacterErrorText)
            .Must(Common.BeAValidFreeText)
            .WithMessage(VacancyViewModelMessages.DesiredSkills.WhiteListInvalidTagErrorText)
            .When(x => Common.IsNotEmpty(x.DesiredSkills));

            validator.RuleFor(x => x.FutureProspects)
            .Matches(VacancyViewModelMessages.FutureProspects.WhiteListHtmlRegularExpression)
            .WithMessage(VacancyViewModelMessages.FutureProspects.WhiteListInvalidCharacterErrorText)
            .Must(Common.BeAValidFreeText)
            .WithMessage(VacancyViewModelMessages.FutureProspects.WhiteListInvalidTagErrorText)
            .When(x => Common.IsNotEmpty(x.FutureProspects));

            validator.RuleFor(x => x.PersonalQualities)
            .Matches(VacancyViewModelMessages.PersonalQualities.WhiteListHtmlRegularExpression)
            .WithMessage(VacancyViewModelMessages.PersonalQualities.WhiteListInvalidCharacterErrorText)
            .Must(Common.BeAValidFreeText)
            .WithMessage(VacancyViewModelMessages.PersonalQualities.WhiteListInvalidTagErrorText)
            .When(x => Common.IsNotEmpty(x.PersonalQualities));

            validator.RuleFor(x => x.ThingsToConsider)
            .Matches(VacancyViewModelMessages.ThingsToConsider.WhiteListHtmlRegularExpression)
            .WithMessage(VacancyViewModelMessages.ThingsToConsider.WhiteListInvalidCharacterErrorText)
            .When(x => !string.IsNullOrEmpty(x.ThingsToConsider))     //Migrated vacancies can contain just the empty string
            .Must(Common.BeAValidFreeText)
            .WithMessage(VacancyViewModelMessages.ThingsToConsider.WhiteListInvalidTagErrorText);

            validator.RuleFor(x => x.DesiredQualifications)
            .Matches(VacancyViewModelMessages.DesiredQualifications.WhiteListHtmlRegularExpression)
            .WithMessage(VacancyViewModelMessages.DesiredQualifications.WhiteListInvalidCharacterErrorText)
            .Must(Common.BeAValidFreeText)
            .WithMessage(VacancyViewModelMessages.DesiredQualifications.WhiteListInvalidTagErrorText)
            .When(x => Common.IsNotEmpty(x.DesiredQualifications));
        }