public FluentVacancyValidator( ITimeProvider timeProvider, IMinimumWageProvider minimumWageService, IApprenticeshipProgrammeProvider apprenticeshipProgrammesProvider, IQualificationsProvider qualificationsProvider, IHtmlSanitizerService htmlSanitizerService, ITrainingProviderSummaryProvider trainingProviderSummaryProvider, IBlockedOrganisationQuery blockedOrganisationRepo, IProfanityListProvider profanityListProvider, IProviderRelationshipsService providerRelationshipService) { _timeProvider = timeProvider; _minimumWageService = minimumWageService; _qualificationsProvider = qualificationsProvider; _apprenticeshipProgrammesProvider = apprenticeshipProgrammesProvider; _htmlSanitizerService = htmlSanitizerService; _trainingProviderSummaryProvider = trainingProviderSummaryProvider; _blockedOrganisationRepo = blockedOrganisationRepo; _profanityListProvider = profanityListProvider; _providerRelationshipService = providerRelationshipService; SingleFieldValidations(); CrossFieldValidations(); }
public VacancyProfanityChecksRule(IProfanityListProvider profanityListProvider, ConsolidationOption consolidationOption = ConsolidationOption.NoConsolidation, decimal weighting = 100.0m) : base(RuleId.ProfanityChecks, consolidationOption, weighting) { _profanityListProvider = profanityListProvider; }
public VacancyRuleSet(QaRulesConfiguration qaRulesConfig, IApprenticeshipProgrammeProvider apprenticeshipProgrammeProvider, IProfanityListProvider profanityListProvider, IBannedPhrasesProvider bannedPhrasesProvider, IGetTitlePopularity popularityService) : base(nameof(VacancyRuleSet)) { AddRule(new VacancyProfanityChecksRule(profanityListProvider)); AddRule(new VacancyBannedPhraseChecksRule(bannedPhrasesProvider)); AddRule(new VacancyTitlePopularityCheckRule(apprenticeshipProgrammeProvider, popularityService, qaRulesConfig)); }
internal ContactDetailValidator(long ruleId, IProfanityListProvider profanityListProvider) { RuleFor(x => x.Name) .MaximumLength(100) .WithMessage("Contact name must not exceed {MaxLength} characters") .WithErrorCode("90") .ValidFreeTextCharacters() .WithMessage("Contact name contains some invalid characters") .WithErrorCode("91") .ProfanityCheck(profanityListProvider) .WithMessage("Contact name must not contain a banned word or phrase") .WithErrorCode("615") .WithRuleId(ruleId); RuleFor(x => x.Email) .MaximumLength(100) .WithMessage("Email address must not exceed {MaxLength} characters") .WithErrorCode("92") .ValidFreeTextCharacters() .WithMessage("Email address contains some invalid characters") .WithErrorCode("93") .Matches(ValidationConstants.EmailAddressRegex) .WithMessage("Email address must be in a valid format") .WithErrorCode("94") .When(v => !string.IsNullOrEmpty(v.Email)) .ProfanityCheck(profanityListProvider) .WithMessage("Email address must not contain a banned word or phrase") .WithErrorCode("616") .WithRuleId(ruleId); RuleFor(x => x.Phone) .MaximumLength(16) .WithMessage("Contact number must not exceed {MaxLength} digits") .WithErrorCode("95") .MinimumLength(8) .WithMessage("Contact number must be more than {MinLength} digits") .WithErrorCode("96") .Matches(ValidationConstants.PhoneNumberRegex) .WithMessage("Contact number contains some invalid characters") .WithErrorCode("97") .When(v => !string.IsNullOrEmpty(v.Phone)) .WithRuleId(ruleId); }
public ApplicationReviewEditModelValidator(IProfanityListProvider profanityListProvider) { RuleFor(x => x.Outcome) .NotNull() .WithMessage(ApplicationReviewValidator.OutcomeRequired); When(x => x.Outcome == ApplicationReviewStatus.Unsuccessful, () => { RuleFor(x => x.CandidateFeedback) .NotEmpty() .WithMessage(ApplicationReviewValidator.CandidateFeedbackRequired) .MaximumLength(ApplicationReviewValidator.CandidateFeedbackMaxLength) .WithMessage(string.Format(ApplicationReviewValidator.CandidateFeedbackLength, ApplicationReviewValidator.CandidateFeedbackMaxLength)) .ValidFreeTextCharacters() .WithMessage(ApplicationReviewValidator.CandidateFeedbackFreeTextCharacters) .ProfanityCheck(profanityListProvider) .WithMessage(ApplicationReviewValidator.CandidateFeedbackProfanityPhrases) .WithErrorCode("617"); }); }
public QualificationValidatorBase(long ruleId, IQualificationsProvider qualificationsProvider, IProfanityListProvider profanityListProvider) { _qualificationTypes = qualificationsProvider.GetQualificationsAsync().Result ?? new List <string>(); RuleFor(x => x.QualificationType) .Cascade(CascadeMode.StopOnFirstFailure) .NotEmpty() .WithMessage("Select a qualification") .WithErrorCode("53") .Must(_qualificationTypes.Contains) .WithMessage("Invalid qualification type") .WithErrorCode("57") .WithRuleId(ruleId); RuleFor(x => x.Subject) .NotEmpty() .WithMessage("Enter the subject") .WithErrorCode("54") .MaximumLength(50) .WithMessage("The qualification must not exceed {MaxLength} characters") .WithErrorCode("7") .ValidFreeTextCharacters() .WithMessage("Subject contains some invalid characters") .WithErrorCode("6") .ProfanityCheck(profanityListProvider) .WithMessage("Subject must not contain a banned word or phrase.") .WithErrorCode("618") .WithRuleId(ruleId); RuleFor(x => x.Grade) .NotEmpty() .WithMessage("Enter the grade") .WithErrorCode("55") .MaximumLength(30) .WithMessage("The grade should be no longer than {MaxLength} characters") .WithErrorCode("7") .ValidFreeTextCharacters() .WithMessage("Grade contains some invalid characters") .WithErrorCode("6") .ProfanityCheck(profanityListProvider) .WithMessage("Grade must not contain a banned word or phrase.") .WithErrorCode("619") .WithRuleId(ruleId); When(x => x.QualificationType != null && x.QualificationType.Contains("GCSE"), () => { RuleFor(x => x.Grade) .Matches("[1-9]") .WithMessage("GCSEs must include the 1-9 grading system") .WithErrorCode("115") .WithRuleId(ruleId); }); RuleFor(x => x.Weighting) .NotEmpty() .WithMessage("Select if this qualification is essential or desirable") .WithErrorCode("56") .WithRuleId(ruleId); }
public QualificationValidatorBase(IQualificationsProvider qualificationsProvider, IProfanityListProvider profanityListProvider) : this(0, qualificationsProvider, profanityListProvider) { }
public VacancyQualificationsValidator(long ruleId, IQualificationsProvider qualificationsProvider, IProfanityListProvider profanityListProvider) : base(ruleId, qualificationsProvider, profanityListProvider) { }
public QualificationValidator(IQualificationsProvider qualificationsProvider, IProfanityListProvider profanityListProvider) : base(qualificationsProvider, profanityListProvider) { }
public static IRuleBuilderOptions <T, string> ProfanityCheck <T>(this IRuleBuilder <T, string> rule, IProfanityListProvider profanityListProvider) { return(rule.SetValidator(new ProfanityCheckValidator(profanityListProvider))); }
public ProfanityCheckValidator(IProfanityListProvider profanityListProvider) : base("{PropertyName} must not contain a banned word or phrase.") { _profanityListProvider = profanityListProvider; }