public SurveyTellOPCModelValidator(SharedLocalizer _localizer) { ValidatorOptions.Global.CascadeMode = CascadeMode.Continue; // PrivacyConcern (Page: page_main) RuleFor(x => x.PrivacyConcern).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.PrivacyConcern).Length(0, 4096).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Complainant_FirstName (Page: page_main) RuleFor(x => x.Complainant_FirstName).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Complainant_LastName (Page: page_main) RuleFor(x => x.Complainant_LastName).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Complainant_Email (Page: page_main) RuleFor(x => x.Complainant_Email).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); RuleFor(x => x.Complainant_Email).EmailAddress() ; // Complainant_PhoneNumber (Page: page_main) RuleFor(x => x.Complainant_PhoneNumber).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); }
public SurveyPBRModelValidator(SharedLocalizer _localizer) { ValidatorOptions.Global.CascadeMode = CascadeMode.Continue; // OrganizationName (Page: page_organization) RuleFor(x => x.OrganizationName).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.OrganizationName).Length(0, 250).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // OrganizationAddress (Page: page_organization) RuleFor(x => x.OrganizationAddress).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.OrganizationAddress).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // OrganizationCity (Page: page_organization) RuleFor(x => x.OrganizationCity).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.OrganizationCity).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // OrganizationProvince (Page: page_organization) RuleFor(x => x.OrganizationProvince).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); // OrganizationProvinceOther (Page: page_organization) RuleFor(x => x.OrganizationProvinceOther).NotEmpty().When(x => x.OrganizationProvince == 14).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.OrganizationProvinceOther).Length(0, 200).When(x => x.OrganizationProvince == 14).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // OrganizationCountry (Page: page_organization) RuleFor(x => x.OrganizationCountry).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); // OrganizationPostalCode (Page: page_organization) RuleFor(x => x.OrganizationPostalCode).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.OrganizationPostalCode).Length(0, 10).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // RepresentativeType (Page: page_organization) RuleFor(x => x.RepresentativeType).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.RepresentativeType).Must(x => new List <string> { "internal_representative", "external_representative" }.Contains(x)).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // ContactName (Page: page_organization) RuleFor(x => x.ContactName).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.ContactName).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // ContactTitle (Page: page_organization) RuleFor(x => x.ContactTitle).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.ContactTitle).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // ContactPhoneWithCountryCode (Page: page_organization) RuleFor(x => x.ContactPhoneWithCountryCode).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.ContactPhoneWithCountryCode).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // ContactPhoneExtension (Page: page_organization) // ContactEmail (Page: page_organization) RuleFor(x => x.ContactEmail).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.ContactEmail).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); RuleFor(x => x.ContactEmail).EmailAddress(); // ContactAddress (Page: page_organization) RuleFor(x => x.ContactAddress).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.ContactAddress).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // ContactCity (Page: page_organization) RuleFor(x => x.ContactCity).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.ContactCity).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // ContactProvince (Page: page_organization) RuleFor(x => x.ContactProvince).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); // ContactProvinceOther (Page: page_organization) RuleFor(x => x.ContactProvinceOther).NotEmpty().When(x => x.ContactProvince == 14).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.ContactProvinceOther).Length(0, 200).When(x => x.ContactProvince == 14).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // ContactCountry (Page: page_organization) RuleFor(x => x.ContactCountry).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); // ContactPostalCode (Page: page_organization) RuleFor(x => x.ContactPostalCode).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.ContactPostalCode).Length(0, 10).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // NumberOfInvidualKnown (Page: page_breach_description_affected) RuleFor(x => x.NumberOfInvidualKnown).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); // NumberOfInvidualAffected (Page: page_breach_description_affected) RuleFor(x => x.NumberOfInvidualAffected).NotEmpty().When(x => x.NumberOfInvidualKnown == true).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); // NumberOfCanadiansAffected (Page: page_breach_description_affected) // NumberAffectedComment (Page: page_breach_description_affected) RuleFor(x => x.NumberAffectedComment).Length(0, 2000).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // DateBreachOccurrenceStart (Page: page_breach_description_dates) RuleFor(x => x.DateBreachOccurrenceStart).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); // DateBreachOccurrenceEnd (Page: page_breach_description_dates) // BreachOccurrenceComment (Page: page_breach_description_dates) RuleFor(x => x.BreachOccurrenceComment).Length(0, 2000).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // TypeOfBreach (Page: page_breach_description_type) RuleFor(x => x.TypeOfBreach).Must(x => new List <string> { "accidental_disclosure", "loss_physical_devices", "theft_physical_devices", "unauthorized_access", "other" }.Contains(x)).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // TypeOfBreachOther (Page: page_breach_description_type) RuleFor(x => x.TypeOfBreachOther).NotEmpty().When(x => x.TypeOfBreach == "other").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.TypeOfBreachOther).Length(0, 2000).When(x => x.TypeOfBreach == "other").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // BreachCircumstanceDescription (Page: page_breach_description_circumstances) RuleFor(x => x.BreachCircumstanceDescription).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.BreachCircumstanceDescription).Length(0, 2000).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // SecuritySafeguardsDescription (Page: page_breach_descriptionsecurity) RuleFor(x => x.SecuritySafeguardsDescription).Length(0, 2000).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // PersonalInformation (Page: page_breach_description_subject) RuleFor(x => x.PersonalInformation).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleForEach(x => x.PersonalInformation).Must(x => new List <string> { "name", "phone_number", "email_address", "account_number", "social_insurance_number" }.Contains(x)).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // SubjectOfBreach (Page: page_breach_description_subject) RuleFor(x => x.SubjectOfBreach).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.SubjectOfBreach).Length(0, 2000).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // IsAffectedNotified (Page: page_notification_steps) RuleFor(x => x.IsAffectedNotified).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); // DateNotificationBegan (Page: page_notification_steps) RuleFor(x => x.DateNotificationBegan).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); // DateNotificationCompleted (Page: page_notification_steps) // MethodOfNotification (Page: page_notification_steps) RuleFor(x => x.MethodOfNotification).Must(x => new List <string> { "directly", "indirectly", "directly_and_indirectly", "not_notified" }.Contains(x)).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // IndirectlyNotificationDescription (Page: page_notification_steps) RuleFor(x => x.IndirectlyNotificationDescription).NotEmpty().When(x => x.MethodOfNotification == "indirectly").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.IndirectlyNotificationDescription).Length(0, 2000).When(x => x.MethodOfNotification == "indirectly").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // NotificationType (Page: page_notification_description) RuleFor(x => x.NotificationType).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleForEach(x => x.NotificationType).Must(x => new List <string> { "letter", "mail", "telephone", "newspaper" }.Contains(x)).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // NotificationDescription (Page: page_notification_description) RuleFor(x => x.NotificationDescription).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.NotificationDescription).Length(0, 2000).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // StepsReduceRisksDescription (Page: page_risk_mitigation_steps) RuleFor(x => x.StepsReduceRisksDescription).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.StepsReduceRisksDescription).Length(0, 2000).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // OrganizationNotified (Page: page_risk_mitigation_organization) RuleFor(x => x.OrganizationNotified).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); // OrganizationDescription (Page: page_risk_mitigation_organization) RuleFor(x => x.OrganizationDescription).NotEmpty().When(x => x.OrganizationNotified == true).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); // StepsReduceRisksFuture (Page: page_risk_mitigation) RuleFor(x => x.StepsReduceRisksFuture).Length(0, 2000).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // OrganizationDescription RuleForEach(x => x.OrganizationDescription).ChildRules(child => { // Name (Page: page_risk_mitigation_organization) child.RuleFor(x => x.Name).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); }).When(x => x.OrganizationNotified == true); }
public SurveyPAModelValidator(SharedLocalizer _localizer) { ValidatorOptions.Global.CascadeMode = CascadeMode.Continue; // FilingComplaintOnOwnBehalf (Page: page_preliminary_info_Authorization_for_Representative) RuleFor(x => x.FilingComplaintOnOwnBehalf).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.FilingComplaintOnOwnBehalf).Must(x => new List <string> { "yourself", "someone_else" }.Contains(x)).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // WhichFederalGovernementInstitutionComplaintAgainst (Page: page_preliminary_info_Identify_institution) RuleFor(x => x.WhichFederalGovernementInstitutionComplaintAgainst).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); // RaisedPrivacyToAtipCoordinator (Page: page_steps_taken_Writing_ATIP_Coordinator) RuleFor(x => x.RaisedPrivacyToAtipCoordinator).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.RaisedPrivacyToAtipCoordinator).Must(x => new List <string> { "yes", "no", "not_sure" }.Contains(x)).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // NatureOfComplaint (Page: page_details_Type_complaint) RuleFor(x => x.NatureOfComplaint).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleForEach(x => x.NatureOfComplaint).Must(x => new List <string> { "NatureOfComplaintDelay", "NatureOfComplaintExtensionOfTime", "NatureOfComplaintDenialOfAccess", "NatureOfComplaintLanguage", "NatureOfComplaintCorrection", "NatureOfComplaintCollection", "NatureOfComplaintUseAndDisclosure", "NatureOfComplaintRetentionAndDisposal", "NatureOfComplaintOther" }.Contains(x)).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // IsEmployee (Page: page_details_description_of_concerns) RuleFor(x => x.IsEmployee).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.IsEmployee).Must(x => new List <string> { "general_public", "employee_government" }.Contains(x)).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // DateSentRequests (Page: page_details_description_of_concerns) RuleFor(x => x.DateSentRequests).NotEmpty().When(x => x.NatureOfComplaint.Intersect(new List <string>() { "NatureOfComplaintDelay", "NatureOfComplaintExtensionOfTime", "NatureOfComplaintDenialOfAccess", "NatureOfComplaintLanguage" }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.DateSentRequests).Length(0, 5000).When(x => x.NatureOfComplaint.Intersect(new List <string>() { "NatureOfComplaintDelay", "NatureOfComplaintExtensionOfTime", "NatureOfComplaintDenialOfAccess", "NatureOfComplaintLanguage" }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // WordingOfRequest (Page: page_details_description_of_concerns) RuleFor(x => x.WordingOfRequest).NotEmpty().When(x => x.NatureOfComplaint.Intersect(new List <string>() { "NatureOfComplaintDelay", "NatureOfComplaintExtensionOfTime", "NatureOfComplaintDenialOfAccess", "NatureOfComplaintLanguage" }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.WordingOfRequest).Length(0, 5000).When(x => x.NatureOfComplaint.Intersect(new List <string>() { "NatureOfComplaintDelay", "NatureOfComplaintExtensionOfTime", "NatureOfComplaintDenialOfAccess", "NatureOfComplaintLanguage" }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // MoreDetailsOfRequest (Page: page_details_description_of_concerns) RuleFor(x => x.MoreDetailsOfRequest).Length(0, 5000).When(x => x.NatureOfComplaint.Intersect(new List <string>() { "NatureOfComplaintDelay", "NatureOfComplaintExtensionOfTime", "NatureOfComplaintDenialOfAccess", "NatureOfComplaintLanguage" }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // DateOfFinalAnswer (Page: page_details_description_of_concerns) RuleFor(x => x.DateOfFinalAnswer).NotEmpty().When(x => x.NatureOfComplaint.Intersect(new List <string>() { "NatureOfComplaintDelay", "NatureOfComplaintExtensionOfTime", "NatureOfComplaintDenialOfAccess", "NatureOfComplaintLanguage" }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.DateOfFinalAnswer).Length(0, 5000).When(x => x.NatureOfComplaint.Intersect(new List <string>() { "NatureOfComplaintDelay", "NatureOfComplaintExtensionOfTime", "NatureOfComplaintDenialOfAccess", "NatureOfComplaintLanguage" }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // DidNoRecordExist (Page: page_details_description_of_concerns) RuleFor(x => x.DidNoRecordExist).NotEmpty().When(x => x.NatureOfComplaint.Intersect(new List <string>() { "NatureOfComplaintDelay", "NatureOfComplaintExtensionOfTime", "NatureOfComplaintDenialOfAccess", "NatureOfComplaintLanguage" }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.DidNoRecordExist).Must(x => new List <string> { "yes", "no" }.Contains(x)).When(x => x.NatureOfComplaint.Intersect(new List <string>() { "NatureOfComplaintDelay", "NatureOfComplaintExtensionOfTime", "NatureOfComplaintDenialOfAccess", "NatureOfComplaintLanguage" }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // PrivacyActSectionsApplied (Page: page_details_description_of_concerns) RuleFor(x => x.PrivacyActSectionsApplied).Length(0, 5000).When(x => x.NatureOfComplaint.Intersect(new List <string>() { "NatureOfComplaintDelay", "NatureOfComplaintExtensionOfTime", "NatureOfComplaintDenialOfAccess", "NatureOfComplaintLanguage" }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // ItemsNotRecieved (Page: page_details_description_of_concerns) RuleFor(x => x.ItemsNotRecieved).Length(0, 5000).When(x => x.NatureOfComplaint.Intersect(new List <string>() { "NatureOfComplaintDelay", "NatureOfComplaintExtensionOfTime", "NatureOfComplaintDenialOfAccess", "NatureOfComplaintLanguage" }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // InstitutionAgreedRequestOnInformalBasis (Page: page_details_description_of_concerns) RuleFor(x => x.InstitutionAgreedRequestOnInformalBasis).NotEmpty().When(x => x.NatureOfComplaint.Intersect(new List <string>() { "NatureOfComplaintDelay", "NatureOfComplaintExtensionOfTime", "NatureOfComplaintDenialOfAccess", "NatureOfComplaintLanguage" }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.InstitutionAgreedRequestOnInformalBasis).Must(x => new List <string> { "yes", "no", "not_sure" }.Contains(x)).When(x => x.NatureOfComplaint.Intersect(new List <string>() { "NatureOfComplaintDelay", "NatureOfComplaintExtensionOfTime", "NatureOfComplaintDenialOfAccess", "NatureOfComplaintLanguage" }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // SummarizeYourConcernsAndAnyStepsTaken (Page: page_details_description_of_concerns) RuleFor(x => x.SummarizeYourConcernsAndAnyStepsTaken).NotEmpty().When(x => x.NatureOfComplaint.Intersect(new List <string>() { "NatureOfComplaintDelay", "NatureOfComplaintExtensionOfTime", "NatureOfComplaintDenialOfAccess", "NatureOfComplaintLanguage" }).Any() && x.NatureOfComplaint.Intersect(new List <string>() { "NatureOfComplaintCorrection", "NatureOfComplaintCollection", "NatureOfComplaintUseAndDisclosure", "NatureOfComplaintRetentionAndDisposal", "NatureOfComplaintOther" }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.SummarizeYourConcernsAndAnyStepsTaken).Length(0, 5000).When(x => x.NatureOfComplaint.Intersect(new List <string>() { "NatureOfComplaintDelay", "NatureOfComplaintExtensionOfTime", "NatureOfComplaintDenialOfAccess", "NatureOfComplaintLanguage" }).Any() && x.NatureOfComplaint.Intersect(new List <string>() { "NatureOfComplaintCorrection", "NatureOfComplaintCollection", "NatureOfComplaintUseAndDisclosure", "NatureOfComplaintRetentionAndDisposal", "NatureOfComplaintOther" }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // SummarizeYourComplaintAndAnyStepsTaken (Page: page_details_description_of_concerns) RuleFor(x => x.SummarizeYourComplaintAndAnyStepsTaken).NotEmpty().When(x => !x.NatureOfComplaint.Intersect(new List <string>() { "NatureOfComplaintDelay", "NatureOfComplaintExtensionOfTime", "NatureOfComplaintDenialOfAccess", "NatureOfComplaintLanguage" }).Any() && x.NatureOfComplaint.Intersect(new List <string>() { "NatureOfComplaintCorrection", "NatureOfComplaintCollection", "NatureOfComplaintUseAndDisclosure", "NatureOfComplaintRetentionAndDisposal", "NatureOfComplaintOther" }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.SummarizeYourComplaintAndAnyStepsTaken).Length(0, 5000).When(x => !x.NatureOfComplaint.Intersect(new List <string>() { "NatureOfComplaintDelay", "NatureOfComplaintExtensionOfTime", "NatureOfComplaintDenialOfAccess", "NatureOfComplaintLanguage" }).Any() && x.NatureOfComplaint.Intersect(new List <string>() { "NatureOfComplaintCorrection", "NatureOfComplaintCollection", "NatureOfComplaintUseAndDisclosure", "NatureOfComplaintRetentionAndDisposal", "NatureOfComplaintOther" }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // WhatWouldResolveYourComplaint (Page: page_details_description_of_concerns) RuleFor(x => x.WhatWouldResolveYourComplaint).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.WhatWouldResolveYourComplaint).Length(0, 5000).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // SummarizeAttemptsToResolvePrivacyMatter (Page: page_details_description_of_concerns) RuleFor(x => x.SummarizeAttemptsToResolvePrivacyMatter).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.SummarizeAttemptsToResolvePrivacyMatter).Length(0, 5000).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // AdditionalComments (Page: page_details_description_of_concerns) RuleFor(x => x.AdditionalComments).Length(0, 5000).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Complainant_HaveYouSubmittedBefore (Page: page_Complainant_representative) RuleFor(x => x.Complainant_HaveYouSubmittedBefore).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Complainant_HaveYouSubmittedBefore).Must(x => new List <string> { "yes", "no" }.Contains(x)).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // Complainant_FormOfAddress (Page: page_Complainant_representative) RuleFor(x => x.Complainant_FormOfAddress).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Complainant_FormOfAddress).Must(x => new List <string> { "Mr.", "Mrs.", "Ms.", "Other" }.Contains(x)).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // Complainant_FirstName (Page: page_Complainant_representative) RuleFor(x => x.Complainant_FirstName).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Complainant_FirstName).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Complainant_LastName (Page: page_Complainant_representative) RuleFor(x => x.Complainant_LastName).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Complainant_LastName).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Complainant_Email (Page: page_Complainant_representative) RuleFor(x => x.Complainant_Email).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Complainant_Email).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); RuleFor(x => x.Complainant_Email).EmailAddress(); // Complainant_MailingAddress (Page: page_Complainant_representative) RuleFor(x => x.Complainant_MailingAddress).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Complainant_MailingAddress).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Complainant_City (Page: page_Complainant_representative) RuleFor(x => x.Complainant_City).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Complainant_City).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Complainant_Country (Page: page_Complainant_representative) RuleFor(x => x.Complainant_Country).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); // Complainant_ProvinceOrState (Page: page_Complainant_representative) RuleFor(x => x.Complainant_ProvinceOrState).NotEmpty().When(x => x.Complainant_Country == "CA").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); // Complainant_PostalCode (Page: page_Complainant_representative) RuleFor(x => x.Complainant_PostalCode).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Complainant_PostalCode).Length(0, 7).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Complainant_DayTimeNumber (Page: page_Complainant_representative) RuleFor(x => x.Complainant_DayTimeNumber).NotEmpty().When(x => x.FilingComplaintOnOwnBehalf == "yourself").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Complainant_DayTimeNumber).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Complainant_DayTimeNumberExtension (Page: page_Complainant_representative) // Complainant_AltTelephoneNumber (Page: page_Complainant_representative) RuleFor(x => x.Complainant_AltTelephoneNumber).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Complainant_AltTelephoneNumberExtension (Page: page_Complainant_representative) // Reprensentative_FormOfAddress (Page: page_Complainant_representative) RuleFor(x => x.Reprensentative_FormOfAddress).NotEmpty().When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Reprensentative_FormOfAddress).Must(x => new List <string> { "Mr.", "Mrs.", "Ms.", "Other" }.Contains(x)).When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // Reprensentative_FirstName (Page: page_Complainant_representative) RuleFor(x => x.Reprensentative_FirstName).NotEmpty().When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Reprensentative_FirstName).Length(0, 200).When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Reprensentative_LastName (Page: page_Complainant_representative) RuleFor(x => x.Reprensentative_LastName).NotEmpty().When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Reprensentative_LastName).Length(0, 200).When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Reprensentative_Email (Page: page_Complainant_representative) RuleFor(x => x.Reprensentative_Email).NotEmpty().When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Reprensentative_Email).Length(0, 200).When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); RuleFor(x => x.Reprensentative_Email).EmailAddress().When(x => x.FilingComplaintOnOwnBehalf == "someone_else"); // Reprensentative_MailingAddress (Page: page_Complainant_representative) RuleFor(x => x.Reprensentative_MailingAddress).NotEmpty().When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Reprensentative_MailingAddress).Length(0, 200).When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Reprensentative_City (Page: page_Complainant_representative) RuleFor(x => x.Reprensentative_City).NotEmpty().When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Reprensentative_City).Length(0, 200).When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Reprensentative_Country (Page: page_Complainant_representative) RuleFor(x => x.Reprensentative_Country).NotEmpty().When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); // Reprensentative_ProvinceOrState (Page: page_Complainant_representative) RuleFor(x => x.Reprensentative_ProvinceOrState).NotEmpty().When(x => x.FilingComplaintOnOwnBehalf == "someone_else" && x.Reprensentative_Country == "CA").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); // Reprensentative_PostalCode (Page: page_Complainant_representative) RuleFor(x => x.Reprensentative_PostalCode).NotEmpty().When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Reprensentative_PostalCode).Length(0, 7).When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Reprensentative_DayTimeNumber (Page: page_Complainant_representative) RuleFor(x => x.Reprensentative_DayTimeNumber).NotEmpty().When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Reprensentative_DayTimeNumber).Length(0, 200).When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Reprensentative_DayTimeNumberExtension (Page: page_Complainant_representative) // Reprensentative_AltTelephoneNumber (Page: page_Complainant_representative) RuleFor(x => x.Reprensentative_AltTelephoneNumber).Length(0, 200).When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Reprensentative_AltTelephoneNumberExtension (Page: page_Complainant_representative) // NeedsDisabilityAccommodation (Page: page_Complainant_representative) RuleFor(x => x.NeedsDisabilityAccommodation).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.NeedsDisabilityAccommodation).Must(x => new List <string> { "yes", "no" }.Contains(x)).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // DisabilityAccommodation (Page: page_Complainant_representative) RuleFor(x => x.DisabilityAccommodation).NotEmpty().When(x => x.NeedsDisabilityAccommodation == "yes").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.DisabilityAccommodation).Length(0, 5000).When(x => x.NeedsDisabilityAccommodation == "yes").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Documentation_type (Page: page_documentation) RuleFor(x => x.Documentation_type).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Documentation_type).Must(x => new List <string> { "upload", "mail", "both", "none" }.Contains(x)).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // Documentation_file_upload_rep (Page: page_documentation) RuleFor(x => x.Documentation_file_upload_rep).NotEmpty().When(x => x.FilingComplaintOnOwnBehalf == "someone_else" && (new List <string>() { x.Documentation_type }.Intersect(new List <string>() { "upload", "both" }).Any())).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); // Documentation_file_upload (Page: page_documentation) RuleFor(x => x.Documentation_file_upload).NotEmpty().When(x => new List <string>() { x.Documentation_type }.Intersect(new List <string>() { "upload", "both" }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); // InformationIsTrue (Page: ) RuleFor(x => x.InformationIsTrue).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleForEach(x => x.InformationIsTrue).Must(x => new List <string> { "yes" }.Contains(x)).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); }
public SurveyContactInfoModelValidator(SharedLocalizer _localizer) { ValidatorOptions.Global.CascadeMode = CascadeMode.Continue; // FirstName (Page: page__start) RuleFor(x => x.FirstName).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // LastName (Page: page__start) RuleFor(x => x.LastName).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // PhoneNumber (Page: page__start) RuleFor(x => x.PhoneNumber).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Email (Page: page__start) RuleFor(x => x.Email).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Email).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); RuleFor(x => x.Email).EmailAddress(); // ProvinceOrState (Page: page__start) RuleFor(x => x.ProvinceOrState).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); // ContactingUsAs (Page: page__start) RuleFor(x => x.ContactingUsAs).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.ContactingUsAs).Must(x => new List <string> { "individual", "federal_or_agency", "private_sector", "organization_school_hospital" }.Contains(x)).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // QuestionsRelateTo (Page: page__start) RuleFor(x => x.QuestionsRelateTo).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.QuestionsRelateTo).Must(x => new List <string> { "individual", "federal_or_agency", "private_sector", "organization_school_hospital" }.Contains(x)).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // TopicOfEnquiry (Page: page_topics) RuleForEach(x => x.TopicOfEnquiry).Must(x => new List <string> { "personal_information", "advertising_marketing", "air_travel", "authentication_identification", "behavioural_advertising", "biometrics", "businesses_collection_pi", "businesses_safeguarding_pi", "casl_spam", "cloud", "compliance", "consent", "driver_licence", "electronic_disclosure_tribunal_decisions", "complaint_pipeda", "genetic_privacy", "gps", "health_information", "identity_theft", "online_privacy", "jurisdiction", "landlords_tenants", "non_profit_sector", "OPC_role_mandate", "outsourcing", "personal_financial_information", "privacy_kids", "privacy_breaches", "impact_assessments", "privacy_policies", "safety_law_enforcement", "sin", "social_networking", "surveillance_monitoring", "technology_privacy", "workplace_privacy", "privacy_rights" }.Contains(x)).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // QuestionToInformationCenterDetails (Page: page_question_details) RuleFor(x => x.QuestionToInformationCenterDetails).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.QuestionToInformationCenterDetails).Length(0, 2000).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); }
public IActionResult ValidateAttachments([FromBody] PAFilePageData files, [FromQuery] string complaintId) { //throw new Exception("this is a test exception", new Exception("this is the inner exception")); //ValidationProblemDetails valid = new ValidationProblemDetails(); //valid.Detail = "There is errors with the validation, see error list"; //valid.Title = "Validation errors"; //valid.Errors.Add("mykey", new string[] { "value1", "value2" }); //valid.Errors.Add("another mykey", new string[] { "more value1", "stuff" }); //return BadRequest(valid); if (files.Documentation_type == "upload" || files.Documentation_type == "both") { List <SurveyFile> allFiles = new List <SurveyFile>(); if (files.Documentation_file_upload != null) { allFiles.AddRange(files.Documentation_file_upload); } if (files.Documentation_file_upload_rep != null) { allFiles.AddRange(files.Documentation_file_upload_rep); } if (allFiles.Count > 0) { long totalSizes = 0; long multipleFileMaxSize = 26214400; var folderName = Path.Combine("FileUploads", complaintId); var folderpath = Path.Combine(Directory.GetCurrentDirectory(), folderName); if (!Directory.Exists(folderpath)) { Directory.CreateDirectory(folderpath); } DirectoryInfo directory = new DirectoryInfo(folderpath); FileInfo[] filesStored = directory.GetFiles(); // We need to make sure the list of files sent to us saved in local storage (in other words the files the users think he is // uploading) are all saved on the server properly with the right size OPCProblemDetails fileMissingProblem = new OPCProblemDetails { Status = 400, Detail = _localizer.GetLocalizedStringSharedResource("FileNotFound"), Title = _localizer.GetLocalizedStringSharedResource("ValidationIssues") }; foreach (SurveyFile file in allFiles) { long.TryParse(file.content, out long fileSize); if (fileSize == 0 || filesStored.Where(f => f.Name == file.name && f.Length == fileSize).Any() == false) { fileMissingProblem.AddError(_localizer.GetLocalizedStringSharedResource("FileNotFound"), string.Format(_localizer.GetLocalizedStringSharedResource("FileMissing"), file.name)); } else { // We are adding to the total file size that we will process later totalSizes += fileSize; } } if (fileMissingProblem.Errors.Count > 0) { return(BadRequest(fileMissingProblem)); } // Next step is to validate for total file size. if (totalSizes > multipleFileMaxSize) { OPCProblemDetails problem = new OPCProblemDetails { Detail = _localizer.GetLocalizedStringSharedResource("SizeOfFilesExceeded"), Status = 400, Title = _localizer.GetLocalizedStringSharedResource("ValidationIssues") }; problem.Errors.Add(_localizer.GetLocalizedStringSharedResource("Attachments"), new List <string>() { _localizer.GetLocalizedStringSharedResource("SizeOfFilesExceeded") }); return(BadRequest(problem)); } } else { OPCProblemDetails problem = new OPCProblemDetails { Detail = "There is no files uploaded", Status = 400, Title = _localizer.GetLocalizedStringSharedResource("ValidationIssues") }; return(BadRequest(problem)); } } return(Ok()); }
public SurveyPipedaModelValidator(SharedLocalizer _localizer) { ValidatorOptions.Global.CascadeMode = CascadeMode.Continue; // ProvinceIncidence (Page: page_part_a_jurisdiction_province) RuleFor(x => x.ProvinceIncidence).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); // ComplaintAboutHandlingInformationOutsideProvince (Page: page_part_a_jurisdiction_particulars) RuleFor(x => x.ComplaintAboutHandlingInformationOutsideProvince).NotEmpty().When(x => new List <int>() { x.ProvinceIncidence != null ? (int)x.ProvinceIncidence : 0 }.Intersect(new List <int>() { 2, 6, 9 }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.ComplaintAboutHandlingInformationOutsideProvince).Must(x => new List <string> { "yes", "no", "not_sure" }.Contains(x)).When(x => new List <int>() { x.ProvinceIncidence != null ? (int)x.ProvinceIncidence : 0 }.Intersect(new List <int>() { 2, 6, 9 }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // IsAgainstFwub (Page: page_part_a_jurisdiction_particulars) RuleFor(x => x.IsAgainstFwub).NotEmpty().When(x => new List <int>() { x.ProvinceIncidence != null ? (int)x.ProvinceIncidence : 0 }.Intersect(new List <int>() { 2, 6, 9 }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.IsAgainstFwub).Must(x => new List <string> { "yes", "no" }.Contains(x)).When(x => new List <int>() { x.ProvinceIncidence != null ? (int)x.ProvinceIncidence : 0 }.Intersect(new List <int>() { 2, 6, 9 }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // DidOrganizationDirectComplaintToOpc (Page: page_part_a_jurisdiction_particulars) RuleFor(x => x.DidOrganizationDirectComplaintToOpc).NotEmpty().When(x => new List <int>() { x.ProvinceIncidence != null ? (int)x.ProvinceIncidence : 0 }.Intersect(new List <int>() { 2, 6, 9 }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.DidOrganizationDirectComplaintToOpc).Must(x => new List <string> { "yes", "no" }.Contains(x)).When(x => new List <int>() { x.ProvinceIncidence != null ? (int)x.ProvinceIncidence : 0 }.Intersect(new List <int>() { 2, 6, 9 }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // ComplaintAgainstHandlingOfInformation (Page: page_part_a_jurisdiction_provincial) RuleFor(x => x.ComplaintAgainstHandlingOfInformation).NotEmpty().When(x => new List <int>() { x.ProvinceIncidence != null ? (int)x.ProvinceIncidence : 0 }.Intersect(new List <int>() { 1, 3, 4, 5, 7, 8, 10 }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.ComplaintAgainstHandlingOfInformation).Must(x => new List <string> { "yes", "no" }.Contains(x)).When(x => new List <int>() { x.ProvinceIncidence != null ? (int)x.ProvinceIncidence : 0 }.Intersect(new List <int>() { 1, 3, 4, 5, 7, 8, 10 }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // HealthPractitioner (Page: page_part_a_jurisdiction_provincial) RuleFor(x => x.HealthPractitioner).NotEmpty().When(x => new List <int>() { x.ProvinceIncidence != null ? (int)x.ProvinceIncidence : 0 }.Intersect(new List <int>() { 1, 3, 4, 5, 7, 8, 10 }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.HealthPractitioner).Must(x => new List <string> { "yes", "no" }.Contains(x)).When(x => new List <int>() { x.ProvinceIncidence != null ? (int)x.ProvinceIncidence : 0 }.Intersect(new List <int>() { 1, 3, 4, 5, 7, 8, 10 }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // IndependantPhysicalExam (Page: page_part_a_jurisdiction_provincial) RuleFor(x => x.IndependantPhysicalExam).NotEmpty().When(x => new List <int>() { x.ProvinceIncidence != null ? (int)x.ProvinceIncidence : 0 }.Intersect(new List <int>() { 1, 3, 4, 5, 7, 8, 10 }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.IndependantPhysicalExam).Must(x => new List <string> { "yes", "no", "not_applicable" }.Contains(x)).When(x => new List <int>() { x.ProvinceIncidence != null ? (int)x.ProvinceIncidence : 0 }.Intersect(new List <int>() { 1, 3, 4, 5, 7, 8, 10 }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // EmployeeOrCustomer (Page: page_part_a_customer_or_employee) RuleFor(x => x.EmployeeOrCustomer).NotEmpty().When(x => x.ProvinceIncidence <= 10).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.EmployeeOrCustomer).Must(x => new List <string> { "customer", "employee", "other" }.Contains(x)).When(x => x.ProvinceIncidence <= 10).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // AgainstOrganizations (Page: page_part_a_customer_or_employee) RuleFor(x => x.AgainstOrganizations).NotEmpty().When(x => x.ProvinceIncidence <= 10 && new List <int>() { x.ProvinceIncidence != null ? (int)x.ProvinceIncidence : 0 }.Intersect(new List <int>() { 1, 3, 4, 5, 7, 8, 10 }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.AgainstOrganizations).Must(x => new List <string> { "yes", "no" }.Contains(x)).When(x => x.ProvinceIncidence <= 10 && new List <int>() { x.ProvinceIncidence != null ? (int)x.ProvinceIncidence : 0 }.Intersect(new List <int>() { 1, 3, 4, 5, 7, 8, 10 }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // Question3Answers (Page: page_part_a_competence) RuleForEach(x => x.Question3Answers).Must(x => new List <string> { "charity_non_profit", "condominium_corporation", "federal_government", "first_nation", "individual", "journalism", "political_party" }.Contains(x)).When(x => x.ProvinceIncidence <= 10).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // SubmittedComplaintToOtherBody (Page: page_part_b_another_body) RuleFor(x => x.SubmittedComplaintToOtherBody).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); // ComplaintStillOngoing (Page: page_part_b_status_other_complaint) RuleFor(x => x.ComplaintStillOngoing).NotEmpty().When(x => x.SubmittedComplaintToOtherBody == true).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); // AgainstTypeOrganizations (Page: page_part_b_means_recourse) RuleForEach(x => x.AgainstTypeOrganizations).Must(x => new List <string> { "collection_agency", "insurance_company", "landlord", "lawyer", "do_not_call_list", "unsubscribe", "phone_internet_provider", "realtor", "your_employer" }.Contains(x)).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // RaisedConcernToPrivacyOfficer (Page: page_part_b_privacy_officer) RuleFor(x => x.RaisedConcernToPrivacyOfficer).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.RaisedConcernToPrivacyOfficer).Must(x => new List <string> { "yes", "no", "not_sure" }.Contains(x)).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // DeniedAccess (Page: page_part_c_complaint_about_access) RuleFor(x => x.DeniedAccess).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.DeniedAccess).Must(x => new List <string> { "yes", "yes_and_other_concern", "no" }.Contains(x)).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // FilingComplaintOnOwnBehalf (Page: page_part_c_authorization_representative) RuleFor(x => x.FilingComplaintOnOwnBehalf).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.FilingComplaintOnOwnBehalf).Must(x => new List <string> { "yourself", "someone_else" }.Contains(x)).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // InstitutionComplaint (Page: page_part_c_details_complaint) RuleFor(x => x.InstitutionComplaint).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.InstitutionComplaint).Length(0, 5000).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // DateAccessRequests (Page: page_part_c_details_complaint) RuleFor(x => x.DateAccessRequests).NotEmpty().When(x => new List <string>() { x.DeniedAccess }.Intersect(new List <string>() { "yes_and_other_concern", "yes" }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.DateAccessRequests).Length(0, 5000).When(x => new List <string>() { x.DeniedAccess }.Intersect(new List <string>() { "yes_and_other_concern", "yes" }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // AddressesAccessRequest (Page: page_part_c_details_complaint) RuleFor(x => x.AddressesAccessRequest).NotEmpty().When(x => new List <string>() { x.DeniedAccess }.Intersect(new List <string>() { "yes_and_other_concern", "yes" }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.AddressesAccessRequest).Length(0, 5000).When(x => new List <string>() { x.DeniedAccess }.Intersect(new List <string>() { "yes_and_other_concern", "yes" }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // ItemsNotReceived (Page: page_part_c_details_complaint) RuleFor(x => x.ItemsNotReceived).NotEmpty().When(x => new List <string>() { x.DeniedAccess }.Intersect(new List <string>() { "yes_and_other_concern", "yes" }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.ItemsNotReceived).Length(0, 5000).When(x => new List <string>() { x.DeniedAccess }.Intersect(new List <string>() { "yes_and_other_concern", "yes" }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // ComplaintSummary (Page: page_part_c_details_complaint) RuleFor(x => x.ComplaintSummary).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.ComplaintSummary).Length(0, 5000).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // ComplaintToOtherBodyDetails (Page: page_part_c_details_complaint) RuleFor(x => x.ComplaintToOtherBodyDetails).NotEmpty().When(x => x.SubmittedComplaintToOtherBody == true).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.ComplaintToOtherBodyDetails).Length(0, 5000).When(x => x.SubmittedComplaintToOtherBody == true).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // WhatWouldResolveYourComplaint (Page: page_part_c_details_complaint) RuleFor(x => x.WhatWouldResolveYourComplaint).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.WhatWouldResolveYourComplaint).Length(0, 5000).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // EffortsTakenToResolve (Page: page_part_c_details_complaint) RuleFor(x => x.EffortsTakenToResolve).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.EffortsTakenToResolve).Length(0, 5000).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Complainant_HaveYouSubmittedBeforeChoice (Page: page_part_c_complaint_representative) RuleFor(x => x.Complainant_HaveYouSubmittedBeforeChoice).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Complainant_HaveYouSubmittedBeforeChoice).Must(x => new List <string> { "yes", "no" }.Contains(x)).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // Complainant_FormOfAddress (Page: page_part_c_complaint_representative) RuleFor(x => x.Complainant_FormOfAddress).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Complainant_FormOfAddress).Must(x => new List <string> { "Mr.", "Mrs.", "Ms.", "Other" }.Contains(x)).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // Complainant_FirstName (Page: page_part_c_complaint_representative) RuleFor(x => x.Complainant_FirstName).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Complainant_FirstName).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Complainant_LastName (Page: page_part_c_complaint_representative) RuleFor(x => x.Complainant_LastName).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Complainant_LastName).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Complainant_Email (Page: page_part_c_complaint_representative) RuleFor(x => x.Complainant_Email).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Complainant_Email).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); RuleFor(x => x.Complainant_Email).EmailAddress(); // Complainant_MailingAddress (Page: page_part_c_complaint_representative) RuleFor(x => x.Complainant_MailingAddress).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Complainant_MailingAddress).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Complainant_City (Page: page_part_c_complaint_representative) RuleFor(x => x.Complainant_City).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Complainant_City).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Complainant_Country (Page: page_part_c_complaint_representative) RuleFor(x => x.Complainant_Country).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); // Complainant_ProvinceOrState (Page: page_part_c_complaint_representative) RuleFor(x => x.Complainant_ProvinceOrState).NotEmpty().When(x => x.Complainant_Country == "CA").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); // Complainant_PostalCode (Page: page_part_c_complaint_representative) RuleFor(x => x.Complainant_PostalCode).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Complainant_PostalCode).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Complainant_DayTimeNumber (Page: page_part_c_complaint_representative) RuleFor(x => x.Complainant_DayTimeNumber).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Complainant_DayTimeNumberExtension (Page: page_part_c_complaint_representative) // Complainant_AltTelephoneNumber (Page: page_part_c_complaint_representative) RuleFor(x => x.Complainant_AltTelephoneNumber).Length(0, 200).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Complainant_AltTelephoneNumberExtension (Page: page_part_c_complaint_representative) // Reprensentative_FormOfAddress (Page: page_part_c_complaint_representative) RuleFor(x => x.Reprensentative_FormOfAddress).NotEmpty().When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Reprensentative_FormOfAddress).Must(x => new List <string> { "Mr.", "Mrs.", "Ms.", "Other" }.Contains(x)).When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // Reprensentative_FirstName (Page: page_part_c_complaint_representative) RuleFor(x => x.Reprensentative_FirstName).NotEmpty().When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Reprensentative_FirstName).Length(0, 200).When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Reprensentative_LastName (Page: page_part_c_complaint_representative) RuleFor(x => x.Reprensentative_LastName).NotEmpty().When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Reprensentative_LastName).Length(0, 200).When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Reprensentative_Email (Page: page_part_c_complaint_representative) RuleFor(x => x.Reprensentative_Email).NotEmpty().When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Reprensentative_Email).Length(0, 200).When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); RuleFor(x => x.Reprensentative_Email).EmailAddress().When(x => x.FilingComplaintOnOwnBehalf == "someone_else"); // Reprensentative_MailingAddress (Page: page_part_c_complaint_representative) RuleFor(x => x.Reprensentative_MailingAddress).NotEmpty().When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Reprensentative_MailingAddress).Length(0, 200).When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Reprensentative_City (Page: page_part_c_complaint_representative) RuleFor(x => x.Reprensentative_City).NotEmpty().When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Reprensentative_City).Length(0, 200).When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Reprensentative_Country (Page: page_part_c_complaint_representative) RuleFor(x => x.Reprensentative_Country).NotEmpty().When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); // Reprensentative_ProvinceOrState (Page: page_part_c_complaint_representative) RuleFor(x => x.Reprensentative_ProvinceOrState).NotEmpty().When(x => x.FilingComplaintOnOwnBehalf == "someone_else" && x.Reprensentative_Country == "CA").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); // Reprensentative_PostalCode (Page: page_part_c_complaint_representative) RuleFor(x => x.Reprensentative_PostalCode).NotEmpty().When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Reprensentative_PostalCode).Length(0, 200).When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Reprensentative_DayTimeNumber (Page: page_part_c_complaint_representative) RuleFor(x => x.Reprensentative_DayTimeNumber).NotEmpty().When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.Reprensentative_DayTimeNumber).Length(0, 200).When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Reprensentative_DayTimeNumberExtension (Page: page_part_c_complaint_representative) // Reprensentative_AltTelephoneNumber (Page: page_part_c_complaint_representative) RuleFor(x => x.Reprensentative_AltTelephoneNumber).Length(0, 200).When(x => x.FilingComplaintOnOwnBehalf == "someone_else").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // Reprensentative_AltTelephoneNumberExtension (Page: page_part_c_complaint_representative) // NeedsDisabilityAccommodationChoice (Page: page_part_c_complaint_representative) RuleFor(x => x.NeedsDisabilityAccommodationChoice).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.NeedsDisabilityAccommodationChoice).Must(x => new List <string> { "yes", "no" }.Contains(x)).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // DisabilityAccommodation (Page: page_part_c_complaint_representative) RuleFor(x => x.DisabilityAccommodation).NotEmpty().When(x => x.NeedsDisabilityAccommodationChoice == "yes").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.DisabilityAccommodation).Length(0, 5000).When(x => x.NeedsDisabilityAccommodationChoice == "yes").WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsOverCharacterLimit")); // DocumentationType (Page: page_part_c_documentation) RuleFor(x => x.DocumentationType).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleFor(x => x.DocumentationType).Must(x => new List <string> { "upload", "mail", "both", "none" }.Contains(x)).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); // Documentation_file_upload_rep (Page: page_part_c_documentation) RuleFor(x => x.Documentation_file_upload_rep).NotEmpty().When(x => x.FilingComplaintOnOwnBehalf == "someone_else" && new List <string>() { x.DocumentationType }.Intersect(new List <string>() { "upload", "both" }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); // Documentation_file_upload (Page: page_part_c_documentation) RuleFor(x => x.Documentation_file_upload).NotEmpty().When(x => new List <string>() { x.DocumentationType }.Intersect(new List <string>() { "upload", "both" }).Any()).WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); // InformationIsTrue (Page: ) RuleFor(x => x.InformationIsTrue).NotEmpty().WithMessage(_localizer.GetLocalizedStringSharedResource("FieldIsRequired")); RuleForEach(x => x.InformationIsTrue).Must(x => new List <string> { "yes" }.Contains(x)).WithMessage(_localizer.GetLocalizedStringSharedResource("SelectedValueNotValid")); }