PolicyPeriodValidation: validateImpl method
Ideally, the validateImpl
method simply directs the flow of logic. Rather than check for problems
itself, Guidewire recommends instead that the validateImpl method call other
methods, each with a specific purpose. The PolicyPeriodValidation.validateImpl method demonstrates
this approach. (The following is a simplified version of the method code.)
override protected function validateImpl() {
if (not Context.addToVisited(this, "validateImpl")) {
return
}
checkPeriodDates()
checkQuoteNeededDate()
checkProductIsValid()
...
checkAnswers()
...
Period.PolicyContactRoles.each(\ role -> new PolicyContactRoleValidation(Context, role).validate())
accountContact.Values.each(\ roles -> new PolicyContactRoleForSameContactValidation(Context,
roles).validate())
locs.each(\ loc -> new PolicyLocationValidation(Context, loc, validatedTerritoryCodes).validate())
Period.Lines.each(\ line -> validateLine(line, \ validator -> validator.validate()))
checkUniqueKeyBeansHaveNoDuplicates()
checkNamedInsuredIndustryCode()
checkPolicyLocationIndustryCode()
checkReinsuranceForBindablePeriod()
checkPolicyAddress()
modifiers.each(\ m -> new ModifierValidation(Context, m).validate() )
new InvariantValidation(Context, Period).validate()
}
First, validateImpl
registers the fact that it has been called. Notice how the validateImpl method perform no
checks itself. Instead the validateImpl
method calls other methods such as checkPeriodDates
and checkPolicyAddress,
all of which have a very narrowly focused purpose. Also notice that validateImpl chains to validations
for entities held by PolicyPeriod:
PolicyContactRoleValidationPolicyContactRoleForSameContactValidationPolicyLocationValidationPolicyLineValidation
