Caplin Trader 5.1.0

Class: module:ct-trading/validation/DateValidator

module:ct-trading/validation/DateValidator(fields, datePatternopt, forceFutureopt)

The DateValidator is a module:ct-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.


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

The constructor for the DateValidator.

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>

True indicates that the validator should only allow dates that are in the future.



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: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 the error map is added. Must not be null or undefined.

Inherited From:


Performs a validation on the specified field value to determine if it is a valid date.

Name Type Description
value String

The field value to validate.


An error message indicating the validation failure, or null if no errors occurred.