PolicyPeriodValidation validation checks

The PolicyPeriodValidation check methods test for specific conditions. Guidewire strongly recommends that the method name summarize the test condition. The following code is for method checkOfficialIDs. This test ensures that if the validation level is at or above bindable, all required official IDs for the named insured have been set for all states on the policy.

Notice that the check method always registers itself with the Context, whatever the validation level. This is useful for debugging as it makes it clear that the method was called during the course of validation. This is true even if no message was added, which would be the case if no problems were discovered.

private function checkOfficialIDs() {
  Context.addToVisited(this, "checkOfficialIDs")    
  var linePatterns = Period.Lines*.Pattern

   var states = Period.Lines*.CoveredStates.toSet()
  if (Context.isAtLeast(TC_BINDABLE)) {
    // check official IDs for each covered state
    for (covstate in states) {
      var checkOfficialIDs = Period.getNamedInsuredOfficialIDsForState
              (StateJurisdictionMappingUtil.getStateMappingForJurisdiction(covstate))
        .where(\id -> id typeis PCOfficialID and linePatterns.contains(id.Pattern.PolicyLinePattern))
      for (officialID in checkOfficialIDs) {
        officialID.validateOfficialID(Period, Result)
      }
    }
  }
}