Caplin Trader 4.7.1

Class: module:caplin/trading/validation/NotEmptyValidator

module:caplin/trading/validation/NotEmptyValidator

The NotEmptyValidator is a module:caplin/trading/validation/Validator that verifies that the validated data contains all the fields specified in the constructor, and that these fields are not null. This class is immutable.

Constructor

new module:caplin/trading/validation/NotEmptyValidator(fields)

The constructor for the NotEmptyValidator.
Extends:
Parameters:
Name Type Description
fields Array an array field names as strings that must be present in the data to validate. Must not be null.
Throws:
if the mandatory fields is not an array of strings.
Type
module:caplin/core/Error

Extends

Methods

validate(oDataToValidate, oValidationResult)

Validates the supplied data and adds an error map to the validation result if any of the fields are missing, or if the implementing validator deems that the field contains an error. The error object is a map with the field name as the key and the error as the value. Implementing classes should not override this method.
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 the error map is added. Must not be null or undefined.
Inherited From:

validateField(value) → {String}

Performs validation on the specified field to determine if it exists in the mandatory fields.
Parameters:
Name Type Description
value String The field value to validate.
Returns:
An error message indicating the validation failure, or null if no errors occurred.
Type
String