Caplin Trader 4.7.1

Class: module:caplin/core/validator/MapConfigUtility



new module:caplin/core/validator/MapConfigUtility()

Utility class with static method for checking validity of map config object.


(static) checkConfig(config, value:)

Check validity of given map config object.
Name Type Description
config object configuration object specifying the allowed/required keys and values in a map.
Name Type Description
anyAllowed boolean If true, any field or value is allowed, and an optional fields property may be provided to specify if fields are required or have conditions on their values. If false, then a fields property must be provided, which must be a map of field names. Only these field names will be allowed.
fields Object The map of field names
Name Type Description
type String The field's value must have the given type (possible types: var, number, string, flag).
required boolean The field must be present in the map being validated.
minimum Number The field's value must be at least the given minimum (only for numbers).
maximum: Number The field's value must be at most the given maximum (only for numbers).
value: * The field's value must match the given value exactly. Example config objects: This is the simplest possible config object; it allows any field. { anyAllowed: true }
This config object allows any field, and requires that width be present, and have value type number at least 100.
anyAllowed: true,
fields: {
width: { required: true, type: 'number', minimum: 100 } }