Caplin Trader 4.5.2

Class: module:caplin/trading/validation/IntegerValidator


The IntegerValidator is a module:caplin/trading/validation/AbstractFieldValidator that validates an integer value according the to specified domain constraints. This class is immutable.


new module:caplin/trading/validation/IntegerValidator(fields, allowStringsopt, loweropt, upperopt)

The constructor for the IntegerValidator.
Name Type Attributes Default Description
fields Array An array of string field names that must be present in the data to validate. Must not be null.
allowStrings boolean <optional>
true If true, integers may be specified in strings.
lower int <optional>
The minimum value. If not set, the value has no lower bound.
upper int <optional>
The maximum value. If not set, the value has no upper bound.
If the list of fields is not an array of strings, or any of the parameters are of the incorrect type.



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.
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 according to determine if the field value is an integer. If this validator was constructed with a minimum or maximum value (lower, upper), the field value will be checked to determine if it exists within those bounds.
Name Type Description
value String The field value to validate.
An error message indicating the validation failure, or null if no errors occurred.