Skip to content

CertificateHolderAddressValidator

FluentValidation validator for Address, applied as a nested validator by CertificateHolderValidator to check the certificate holder's mailing address. It enforces per-line character limits on Line1/Line2/Line3 (80 characters) and City (30 characters), and requires ZipCode and PlusFourCode to be either empty or purely numeric with fixed maximum lengths (5 and 4 digits respectively).

Purpose

  • Caps Line1, Line2, and Line3 at 80 characters each.
  • Caps City at 30 characters.
  • Requires ZipCode to be at most 5 characters and, if present, to contain only digits.
  • Requires PlusFourCode to be at most 4 characters and, if present, to contain only digits.

Context

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

Public members

Member Signature Purpose
CertificateHolderAddressValidator (constructor) public CertificateHolderAddressValidator() Registers all validation rules for Address: address line length caps, city length cap, and numeric-format/length checks for zip code and plus-four code.

Behavioral notes

  • The zip code and plus-four rules use the regex ^$|^\d+$, so an empty string is treated as valid (these fields are effectively optional) but any non-empty value must be all digits.
  • Length rules use Length(0, n), which allows an empty string but rejects any value longer than n characters, regardless of the regex outcome.
  • All rules are unconditional — this validator does not vary its checks based on whether the enclosing certificate holder's address is foreign; the caller (CertificateHolderValidator) is responsible for deciding when to apply address validation.*

Constraints and usage notes

  • Because zip/zip-plus-four rules accept empty strings as valid, this validator alone does not guarantee a zip code is present; callers needing a mandatory zip code must enforce that separately.*

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