Caplin Trader 5.1.0

Interface: module:ct-trading/validation/Validator

module:ct-trading/validation/Validator

A Validator is used to check data. It appends to the supplied module:ct-trading/validation/ValidationResult object information about any errors found in the data. Multiple Validators may share a module:ct-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:ct-trading/statemachine/StateMachine to change its state just because this Validator has passed as another Validator may have failed. The module:ct-trading/statemachine/StateMachine will determine whether or not all validation has passed by calling module:ct-trading/validation/ValidationResult#getValidationSuccessful on on the shared ValidationResult.

The super constructor of implementors of Validator.

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:ct-trading/trademodel/DataHolder

The data to validate. Must not be null or undefined.

oValidationResult module:ct-trading/validation/ValidationResult

A module:ct-trading/validation/ValidationResult to which information about validations is added. Must not be null or undefined.

Throws:

if there is something wrong with the data to validate or some other exception occurs during validation.

Type
module:ct-core/Error