---
title: clsAddressStructure
summary: API reference for clsAddressStructure.
status: draft
owner: SAIF
last_reviewed: 2026-07-24
library: SAIF.Business
reference_type: package
---

# clsAddressStructure

`clsAddressStructure` is a public class in `SAIF.Business.ContactInfo` that stores domestic and foreign address components, maintains preformatted display lines, and exposes rule-based validation helpers backed by reference-table lookups.

## Purpose
- Stores addressee, alternate-name, identifier, line, city, state, ZIP, county, foreign-postal, and country fields for a customer address.
- Produces up to six formatted address lines plus a combined formatted-address string, with optional name, county, country-name, and HTML formatting behavior.
- Tracks null/empty state for each major address element and provides helper methods that clear linked values such as ZIP+4, county, and country data together.
- Exposes required-field and validation rule callbacks for state, ZIP, country, and Oregon ZIP checks, plus shared lookup helpers that query reference tables through the data portal.

## Context
- Namespace: `SAIF.Business.ContactInfo`
- Assembly/package: `SAIF.Business`

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| `AlternateNameTypes` | `Public Enum AlternateNameTypes` | Enumerates the supported alternate-name prefix modes: `CareOf`, `For`, `Estate`, and `Other`. |
| `ActiveFormating` | `Public Property ActiveFormating() As Boolean` | Enables or disables automatic reformatting when address properties change. |
| `FormatUsingName` | `Public Property FormatUsingName() As Boolean` | Controls whether the formatted address includes the addressee and alternate-name lines. |
| `FormatUsingCountryName` | `Public Property FormatUsingCountryName() As Boolean` | Controls whether foreign-address formatting uses the country name as the last line. |
| `UseCounty` | `Public Property UseCounty() As Boolean` | Controls whether county information is included during formatting. |
| `HTMLFormatting` | `Public Property HTMLFormatting() As Boolean` | Switches formatted-address line breaks between HTML output and CRLF output. |
| `AlternateNameType` | `Public Property AlternateNameType As AlternateNameTypes` | Sets the alternate-name mode and updates the corresponding header text. |
| `AlternateNameHeader` | `Public Property AlternateNameHeader As String` | Stores the header prefix used for the alternate-name line. |
| `AddressIdentifier` | `Public Property AddressIdentifier As String` | Stores the address identifier value. |
| `AdresseeName` | `Public Property AdresseeName() As String` | Stores the addressee name used as the first formatted line when name formatting is enabled. |
| `AlternateName` | `Public Property AlternateName As String` | Stores the alternate addressee line value. |
| `AddressLine1` | `Public Property AddressLine1() As String` | Stores the first street-address line. |
| `AddressLine2` | `Public Property AddressLine2() As String` | Stores the second street-address line. |
| `AddressLine3` | `Public Property AddressLine3() As String` | Stores the third street-address line. |
| `AddressLine4` | `Public Property AddressLine4() As String` | Stores the fourth street-address line. |
| `City` | `Public Property City() As String` | Stores the city name. |
| `StateCode` | `Public Property StateCode() As String` | Stores the state code. |
| `ZipCode` | `Public Property ZipCode() As String` | Stores the 5-digit ZIP code value. |
| `ZipCodeExtension` | `Public Property ZipCodeExtension() As String` | Stores the ZIP+4 extension value. |
| `ZipCodeNumeric` | `Public Property ZipCodeNumeric() As Int32` | Gets or sets the ZIP code through an integer representation. |
| `CountyCode` | `Public Property CountyCode() As String` | Stores the county code. |
| `IsForeign` | `Public Property IsForeign() As Boolean` | Indicates whether the address should be treated as foreign. |
| `ForeignPostalCode` | `Public Property ForeignPostalCode() As String` | Stores the foreign postal code. |
| `CountryCode` | `Public Property CountryCode() As String` | Stores the country code. |
| `CountryName` | `Public Property CountryName() As String` | Stores the country name. |
| `CountryCodeInfo` | `Public ReadOnly Property CountryCodeInfo As CodeMappings.clsCountryCodeInfo` | Returns the mapped country-code information for the current country code. |
| `IsEmpty` | `Public Overridable ReadOnly Property IsEmpty() As Boolean` | Reports whether all stored address, addressee, county, and country fields are blank. |
| `IsComplete` | `Public ReadOnly Property IsComplete() As Boolean` | Reports whether a domestic address has line 1, city, state, and ZIP populated or the address is marked foreign. |
| `MarkOld` | `Public Shadows Sub MarkOld()` | Marks the address structure as not modified. |
| `FormattedAddressLine1` | `Public ReadOnly Property FormattedAddressLine1() As String` | Returns the first formatted address line. |
| `FormattedAddressLine2` | `Public ReadOnly Property FormattedAddressLine2() As String` | Returns the second formatted address line. |
| `FormattedAddressLine3` | `Public ReadOnly Property FormattedAddressLine3() As String` | Returns the third formatted address line. |
| `FormattedAddressLine4` | `Public ReadOnly Property FormattedAddressLine4() As String` | Returns the fourth formatted address line. |
| `FormattedAddressLine5` | `Public ReadOnly Property FormattedAddressLine5() As String` | Returns the fifth formatted address line. |
| `FormattedAddressLine6` | `Public ReadOnly Property FormattedAddressLine6() As String` | Returns the sixth formatted address line. |
| `FormattedAddress` | `Public ReadOnly Property FormattedAddress() As String` | Returns the combined formatted address string. |
| `IsAddressIdentifierNull` | `Public ReadOnly Property IsAddressIdentifierNull As Boolean` | Reports whether the address identifier is empty. |
| `IsAddresseeNameNull` | `Public ReadOnly Property IsAddresseeNameNull As Boolean` | Reports whether the addressee name is empty. |
| `IsAlternateNameNull` | `Public ReadOnly Property IsAlternateNameNull As Boolean` | Reports whether the alternate-name value is empty. |
| `IsAddressLine1Null` | `Public ReadOnly Property IsAddressLine1Null As Boolean` | Reports whether address line 1 is empty. |
| `IsAddressLine2Null` | `Public ReadOnly Property IsAddressLine2Null As Boolean` | Reports whether address line 2 is empty. |
| `IsAddressLine3Null` | `Public ReadOnly Property IsAddressLine3Null As Boolean` | Reports whether address line 3 is empty. |
| `IsAddressLine4Null` | `Public ReadOnly Property IsAddressLine4Null As Boolean` | Reports whether address line 4 is empty. |
| `IsCityNull` | `Public ReadOnly Property IsCityNull As Boolean` | Reports whether the city is empty. |
| `IsStateCodeNull` | `Public ReadOnly Property IsStateCodeNull As Boolean` | Reports whether the state code is empty. |
| `IsZipCodeNull` | `Public ReadOnly Property IsZipCodeNull As Boolean` | Reports whether the ZIP code is empty. |
| `IsZipCodeExtensionNull` | `Public ReadOnly Property IsZipCodeExtensionNull As Boolean` | Reports whether the ZIP+4 extension is empty. |
| `IsCountyCodeNull` | `Public ReadOnly Property IsCountyCodeNull As Boolean` | Reports whether `_CountryCode` is empty, which is the value checked by this implementation. |
| `IsCountryCodeNull` | `Public ReadOnly Property IsCountryCodeNull As Boolean` | Reports whether the country code is empty. |
| `IsCountyNameNull` | `Public ReadOnly Property IsCountyNameNull As Boolean` | Reports whether the county name is empty. |
| `IsCountryNameNull` | `Public ReadOnly Property IsCountryNameNull As Boolean` | Reports whether the country name is empty. |
| `SetAddressIdentifierNull` | `Public Sub SetAddressIdentifierNull()` | Clears the address identifier and marks the object dirty. |
| `SetAddresseeNameNull` | `Public Sub SetAddresseeNameNull()` | Clears the addressee name and marks the object dirty. |
| `SetAlternateNameNull` | `Public Sub SetAlternateNameNull()` | Clears the alternate-name value and marks the object dirty. |
| `SetAddressLine1Null` | `Public Sub SetAddressLine1Null()` | Clears address line 1 and marks the object dirty. |
| `SetAddressLine2Null` | `Public Sub SetAddressLine2Null()` | Clears address line 2 and marks the object dirty. |
| `SetAddressLine3Null` | `Public Sub SetAddressLine3Null()` | Clears address line 3 and marks the object dirty. |
| `SetAddressLine4Null` | `Public Sub SetAddressLine4Null()` | Clears address line 4 and marks the object dirty. |
| `SetCityNull` | `Public Sub SetCityNull()` | Clears the city and marks the object dirty. |
| `SetStateCodeNull` | `Public Sub SetStateCodeNull()` | Clears the state code and marks the object dirty. |
| `SetZipCodeNull` | `Public Sub SetZipCodeNull()` | Clears both the ZIP code and ZIP+4 extension and marks the object dirty. |
| `SetCountyCodeNull` | `Public Sub SetCountyCodeNull()` | Clears both the county code and county name and marks the object dirty. |
| `SetCountryCodeNull` | `Public Sub SetCountryCodeNull()` | Clears both the country code and country name and marks the object dirty. |
| `New` | `Public Sub New(Optional ByVal inEmptyStringIsBlank As Boolean = False)` | Creates an address structure and optionally configures empty smart-string values to behave as blanks. |
| `New` | `Public Sub New(ByVal inDataPortalInfo As IDataPortalInfo, Optional ByVal inEmptyStringIsBlank As Boolean = False)` | Creates an address structure with a data-portal context for reference-data lookups. |
| `AddressRules` | `Public ReadOnly Property AddressRules() As clsAddress.clsRules` | Returns the rule-settings object used to add business rules for this address. |
| `InitializeRules` | `Public Sub InitializeRules()` | Rebuilds the address business-rule collection from the current rule settings. |
| `CityIsRequired` | `Public Function CityIsRequired(ByVal target As Object, ByVal e As clsRuleArgs) As Boolean` | Fails validation when the city is blank and supplies an optional prefixed error message. |
| `StateCodeIsRequired` | `Public Function StateCodeIsRequired(ByVal target As Object, ByVal e As clsRuleArgs) As Boolean` | Fails validation when the state code is blank and supplies an optional prefixed error message. |
| `CountyIsRequired` | `Public Function CountyIsRequired(ByVal target As Object, ByVal e As clsRuleArgs) As Boolean` | Fails validation when the county code is blank and supplies an optional prefixed error message. |
| `CountryCodeIsRequired` | `Public Function CountryCodeIsRequired(ByVal target As Object, ByVal e As clsRuleArgs) As Boolean` | Fails validation when the country code is blank and supplies an optional prefixed error message. |
| `CountryIsRequired` | `Public Function CountryIsRequired(ByVal target As Object, ByVal e As clsRuleArgs) As Boolean` | Fails validation when the country name is blank and supplies an optional prefixed error message. |
| `AddressLine1IsRequired` | `Public Function AddressLine1IsRequired(ByVal target As Object, ByVal e As clsRuleArgs) As Boolean` | Fails validation when address line 1 is blank and supplies an optional prefixed error message. |
| `AddressLine2IsRequired` | `Public Function AddressLine2IsRequired(ByVal target As Object, ByVal e As clsRuleArgs) As Boolean` | Fails validation when address line 2 is blank and supplies an optional prefixed error message. |
| `AddressLine3IsRequired` | `Public Function AddressLine3IsRequired(ByVal target As Object, ByVal e As clsRuleArgs) As Boolean` | Fails validation when address line 3 is blank and supplies an optional prefixed error message. |
| `AddressLine4IsRequired` | `Public Function AddressLine4IsRequired(ByVal target As Object, ByVal e As clsRuleArgs) As Boolean` | Fails validation when address line 4 is blank and supplies an optional prefixed error message. |
| `ZipCodeIsRequired` | `Public Function ZipCodeIsRequired(ByVal target As Object, ByVal e As clsRuleArgs) As Boolean` | Fails validation when the ZIP code is blank and supplies an optional prefixed error message. |
| `ZipCodePlus4IsRequired` | `Public Function ZipCodePlus4IsRequired(ByVal target As Object, ByVal e As clsRuleArgs) As Boolean` | Fails validation when the ZIP+4 extension is blank and supplies an optional prefixed error message. |
| `NameIsRequired` | `Public Function NameIsRequired(ByVal target As Object, ByVal e As clsRuleArgs) As Boolean` | Fails validation when the addressee name is blank and supplies an optional prefixed error message. |
| `IsStateCodeValid` | `Public Function IsStateCodeValid(ByVal target As Object, ByVal e As clsRuleArgs) As Boolean` | Validates the current state code against reference data when a state code is present. |
| `IsZipCodeExtValid` | `Public Function IsZipCodeExtValid(ByVal target As Object, ByVal e As clsRuleArgs) As Boolean` | Validates that a populated ZIP+4 extension is exactly four characters long. |
| `IsCountryCodeValid` | `Public Function IsCountryCodeValid(ByVal target As Object, ByVal e As clsRuleArgs) As Boolean` | Validates the current country code against reference data when a country code is present. |
| `IsZipCodeValid` | `Public Function IsZipCodeValid(ByVal target As Object, ByVal e As clsRuleArgs) As Boolean` | Validates that a populated ZIP code is exactly five characters long. |
| `IsStateZipCodeValid` | `Public Function IsStateZipCodeValid(ByVal target As Object, ByVal e As clsRuleArgs) As Boolean` | Validates that the ZIP code falls within the current state's configured ZIP ranges. |
| `IsOregonZipCodeValid` | `Public Function IsOregonZipCodeValid(ByVal target As Object, ByVal e As clsRuleArgs) As Boolean` | Validates Oregon ZIP codes against the Oregon-specific reference table when the state is `OR`. |
| `ValidStateCode` | `Public Shared Function ValidStateCode(ByVal inDataPortalInfo As IDataPortalInfo, ByVal inStateCode As String) As Boolean` | Queries `ALL_STATES` and returns whether the supplied state code exists. |
| `ValidCountryCode` | `Public Shared Function ValidCountryCode(ByVal inDataPortalInfo As IDataPortalInfo, ByVal inCountryCode As String) As Boolean` | Queries `COUNTRY` and returns whether the supplied country code exists. |
| `ValidStateZip` | `Public Shared Function ValidStateZip(ByVal inDataPortalInfo As IDataPortalInfo, ByVal inStateCode As String, ByVal inZipCode As String) As Boolean` | Queries `ZIP_CODE` and returns whether the ZIP code is valid for the supplied state. |
| `GetCountryName` | `Public Shared Function GetCountryName(ByVal inDataPortalInfo As IDataPortalInfo, ByVal inCountryCode As String) As String` | Queries `COUNTRY` and returns the country name for the supplied country code. |
| `ValidOregonZip` | `Public Shared Function ValidOregonZip(ByVal inDataPortalInfo As IDataPortalInfo, ByVal inZipCode As String) As Boolean` | Queries `ZIP_MCO_COUNTY` and returns whether the ZIP code is valid for Oregon-specific checks. |
| `clsRules` | `<Serializable()> Public Class clsRules` | Defines the serializable rule-settings type used to control required-field and validation behavior for the address. |

## Behavioral notes
- When `ActiveFormating` is `True`, formatting-option setters and address-field setters call `Format()` to rebuild the formatted lines.
- `Format()` routes foreign addresses through `FormatForeign()` and domestic addresses through `FormatUS()`.
- `SetZipCodeNull()` also clears `ZipCodeExtension`, `SetCountyCodeNull()` also clears `CountyName`, and `SetCountryCodeNull()` also clears `CountryName`.
- `IsCountyCodeNull` checks `_CountryCode.IsEmpty` in the source implementation.

## Constraints and usage notes
- Database-backed validation helpers and `CountryCodeInfo` require a usable `IDataPortalInfo` to resolve reference data.
- `InitializeRules()` must be called after configuring `AddressRules` when callers need the selected rules added to the business-rule collection.
- Shared validation methods depend on the `ALL_STATES`, `COUNTRY`, `ZIP_CODE`, and `ZIP_MCO_COUNTY` reference tables.

## Sources
- `Business\SAIF.Business\ContactInfo\clsAddressStructure.vb`

