Class
caplin.core.validator

MapConfigUtility

Constructor Summary

Attributes Name and Description
caplin.core.validator.MapConfigUtility()

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

Method Summary

Attributes Name and Description
<static> void checkConfig(object config)

Check validity of given map config object.

Constructor Detail

caplin.core.validator.MapConfigUtility()

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

Method Detail

<static> void checkConfig(object config)

Check validity of given map config object.

Parameters
object config configuration object specifying the allowed/required keys and values in a map.

config must have an anyAllowed property, set to a boolean.

If anyAllowed is true, then 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 anyAllowed is false, then a fields property must be provided, which must be a map of field names. Only these field names will be allowed.

For each field name in fields, a map can be provided specifying the following:
  • type (required): The field's value must have the given type (possible types: var, number, string, flag).
  • required: The field must be present in the map being validated.
  • minimum: The field's value must be at least the given minimum (only for numbers).
  • maximum: 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 } }
}
}