Skip to content

CertificateHolderValidator

FluentValidation validator for CertificateHolderEdit, the entity representing the party named on a certificate of insurance. It enforces required and length-limited holder names, optional-but-format-checked email address, a required policy number, fax number format (skipped for foreign addresses), a minimum-contact-information rule requiring at least an email, fax, or complete domestic address, and delegates full address validation to a nested CertificateHolderAddressValidator.

Purpose

  • Requires Name1 (1–100 characters) and caps Name2 at 100 characters.
  • Validates EmailAddress format (when present) and caps it at 60 characters.
  • Requires PolicyNumber to be non-empty.
  • Validates fax number format for domestic addresses, skipping the check when Address.IsForeign is true.
  • Requires the certificate holder to have at least an email address, a fax number, or a complete domestic address (line 1, city, and zip code), via HasMinimumAddress; foreign addresses are always accepted.
  • Delegates structural address validation (line lengths, zip/zip+4 format) to CertificateHolderAddressValidator.

Context

  • Namespace: SAIF.Services.Policies.Certificates.Validators
  • Assembly/package: SAIF.Services (packaged inside the SAIF.SAIFCode.Core NuGet package).

Public members

Member Signature Purpose
CertificateHolderValidator (constructor) public CertificateHolderValidator() Registers all validation rules for CertificateHolderEdit: name requirements/lengths, email format/length, required policy number, conditional fax format check, minimum-contact-information check, and nested address validation via CertificateHolderAddressValidator.

Behavioral notes

  • BeAvalidFaxNumber (private) rejects a fax whose NumericValue is positive but FormattedValue is empty; it accepts any 12-character formatted value or an empty one, and falls through to true otherwise, so its practical rejection case is narrow.*
  • HasMinimumAddress (private) returns true immediately if certEdit or address is null, if an email address is present, if a fax number is present, or if the address is foreign — the domestic-completeness check (line 1, city, zip all present) only applies when none of those short-circuits fire.
  • A source comment ("todo: sync up messages with client") indicates the validation error messages have not yet been finalized against client requirements.*
  • The fax-format rule is explicitly skipped .When(n => !n.Address.IsForeign), so foreign-address certificate holders are never subject to domestic fax-format checks.

Constraints and usage notes

  • A new CertificateHolderAddressValidator instance is constructed per validation run rather than injected, coupling this validator directly to that concrete type.*
  • Callers must ensure certEdit.Address is non-null before validation, since HasMinimumAddress and the fax-format .When clause both dereference Address members.

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/CertificateHolderValidator.cs