Validation

Overview

Validation is the process of verifying that an entity instance conforms to the expectations of the implementer. It is run on various key entities before they are committed, and the process is executed in two steps;

  • First - verifying adherence to entity’s schema as defined in the configuration.

  • Second - any custom business logic or constraints the implementer chooses to impose.

It is the custom validation logic of the second step that is implemented in the Validation Plugin.

Note

The custom validation step is only executed if the schema validation has passed.

Unlike pricing and underwriting which are actions exclusive to quotes and transactions, many other entities also require validation and so can be subject to the validation plugin. Once successfully validated, entities transition to the validated state and are generally immutable.

The following entities are subject to validation:

  • Accounts

  • Quotes

  • Transactions

  • Payments

  • Disbursements

  • Delinquencies

Plugin Execution

Assuming the appropriate override method for each supported entity has been implemented, upon a validation API request and successful schema validation, the validation plugin will be executed and passed the following context;

  • Entity specific Customer Object

Regardless the of the actual entity being dealt with, the plugin must return a ValidationItemResponse. If the ValidationItemResponse is empty, i.e. no entity type, locator and errors, the validation result will be pass.

Account

Case: Account of type ConsumerAccount is defined in configuration

// Returning a populated validation item when the account tier value
// is found to be silver

@Override
 public ValidationItem validate(ConsumerAccountRequest consumerAccountRequest) {
     ConsumerAccount consumerAccount = consumerAccountRequest.account();
     if(consumerAccount.data().tier().equalsIgnoreCase("silver")) {
        return ValidationItem.builder().elementType(consumerAccount.type())
                 .locator(consumerAccount.locator())
                 .addErrors("Can't validate an account with tier value of silver",
                                 "some other error message")
                 .build();
             }
     // Otherwise return an empty validation item
     return ValidationItem.builder().build();
 }

Quote

Case: Product of type PersonalAuto is defined in configuration

// Returning a populated validation item when the fraud value is "yes"
// is found to be silver

@Override
public ValidationItem validate(PersonalAutoQuoteRequest personalAutoQuoteRequest) {
    if(personalAutoQuoteRequest.quote().data().fraud().equalsIgnoreCase("yes")){
        return ValidationItem.builder()
                .elementType(personalAutoQuoteRequest.quote().type())
                .locator(personalAutoQuoteRequest.quote().locator())
                .addErrors("Cannot validate a quote where fraud value is yes")
                .build();
    }
    // Otherwise return an empty validation item
    return ValidationItem.builder().build();
}

Note

Examples for the other entities will follow in a later release.