CertificatePreferenceValidator¶
FluentValidation validator for CertificatePreferenceEdit, the model that captures how a policyholder wants certificate renewal notifications delivered (mail, email, or fax). It requires a delivery method, requires a renewal notification type whenever a delivery method other than None is selected, validates email address format and length, requires an email address when the delivery method is Email, requires a fax number when the delivery method is Fax, and independently validates fax number formatting via BeAvalidFaxNumber.
Purpose¶
- Requires
DeliveryMethodto be set on every submission. - Requires a valid (non-
NotSet)RenewalNotificationTypewheneverDeliveryMethodis notNone. - Enforces email address format/length rules and requires an email address when
DeliveryMethodisEmail. - Requires a fax number when
DeliveryMethodisFax, and validates the fax number's format regardless of delivery method.
Context¶
- Namespace:
SAIF.Services.Policies.Certificates.Validators - Assembly/package:
SAIF.Services(packaged inside theSAIF.SAIFCode.CoreNuGet package).
Public members¶
| Member | Signature | Purpose |
|---|---|---|
| CertificatePreferenceValidator (constructor) | public CertificatePreferenceValidator() |
Registers all validation rules for CertificatePreferenceEdit: required delivery method, conditional renewal-notification requirement, email format/length rules, conditional email/fax requirements based on delivery method, and fax-format validation. |
Behavioral notes¶
- The renewal-notification rule uses
Mustwith a lambda that ignores the boundtestStringparameter and instead re-readsn.RenewalNotificationType, so the rule effectively re-validates the same property it is attached to (DeliveryMethod) via a side-channel check onRenewalNotificationType.* - The email-required and fax-required rules are likewise implemented as
Mustpredicates on theDeliveryMethodproperty that inspectEmailAddress/Faxrather than validating those properties directly, so validation failures surface against theDeliveryMethodfield.* BeAvalidFaxNumbertreats a nullfaxvalue or an empty formatted value as valid, and only rejects a fax whoseNumericValueis positive but whoseFormattedValueis empty, or accepts any formatted value that is exactly 12 characters long; any other non-empty formatted value falls through toreturn trueas well, so the practical rejection case is narrow.*- Several alternative/experimental rule blocks for delivery-method-conditioned messaging are commented out in source, indicating earlier iterations of this validator were replaced.*
Constraints and usage notes¶
- Callers must populate
DeliveryMethodbefore validation, since several rules key off its value to decide whether email or fax fields are mandatory. - The email length rule caps
EmailAddressat 60 characters to match backing storage.
Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with ** could not be confirmed; treat as unknown until verified.
Sources¶
Services/SAIF.Services/Policies/Certificates/Validators/CertificatePreferenceValidator.cs