Caplin Trader 4.7.1

Interface: module:caplin/trading/validation/Validator

module:caplin/trading/validation/Validator

A Validator is used to check data. It appends to the supplied module:caplin/trading/validation/ValidationResult object information about any errors found in the data. Multiple Validators may share a module:caplin/trading/validation/ValidationResult. If validation fails, errors should be added to the shared ValidationResult object. The ValidationResult object knows validation has failed if any errors have been added.

It is recommended that Validators do not have state. It is important that no Validator expects the module:caplin/trading/statemachine/StateMachine to change its state just because this Validator has passed as another Validator may have failed. The module:caplin/trading/statemachine/StateMachine will determine whether or not all validation has passed by calling module:caplin/trading/validation/ValidationResult#getValidationSuccessful on on the shared ValidationResult.

Methods

validate(oDataToValidate, oValidationResult)

Performs the validation on oDataToValidate according to rules in the class that implements the interface and appends information about errors found to oValidationResult.
Parameters:
Name Type Description
oDataToValidate module:caplin/trading/trademodel/DataHolder The data to validate. Must not be null or undefined.
oValidationResult module:caplin/trading/validation/ValidationResult A module:caplin/trading/validation/ValidationResult to which information about validations is added. Must not be null or undefined.
Implementations:
Throws:
if there is something wrong with the data to validate or some other exception occurs during validation.
Type
module:caplin/core/Error