Caplin Trader 4.0.3

Class: module:caplin/trading/validation/DateValidator

module:caplin/trading/validation/DateValidator

Summary

The DateValidator is a module:caplin/trading/validation/Validator that provides functions to ensure supplied data contains valid dates.

The DateValidator uses Moment.js for date parsing. Refer to the Moment.js API documentation for further details of the pattern characters.

Constructor

new module:caplin/trading/validation/DateValidator(fields, datePatternopt, forceFutureopt)

The constructor for the DateValidator.
Parameters:
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.
datePattern String <optional>
A string representing the pattern of the date format to recognise.
forceFuture boolean <optional>
false True indicates that the validator should only allow dates that are in the future.

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)

Performs a validation on the specified field value to determine if it is a valid date.
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.