Coral.validate is a set of property value validation functions for use in Coral components.

Coral.validate API

Property value validators

Methods

Coral.validate.enumeration

Ensures that the new value is within the enumeration. The enumeration can be given as an array of values or as a key/value Object. Take into consideration that enumerations are case sensitive.
Parameters:
Name Type Description
enumeration Object Object that represents an enum.
Returns:
a validation function that ensures that the given value is within the enumeration. {Coral.validate~validationFunction}
Examples
// Enumeration as Array
Coral.validate.enumeration(['xs', 's', 'm', 'l']);
  
// Enumeration as Object
Coral.validate.enumeration({EXTRA_SMALL : 'xs', SMALL : 's', MEDIUM : 'm', LARGE : 'l'});
  

Coral.validate.valueMustChange

Ensures that the value has changed.
Parameters:
Name Type Description
newValue * The new value.
oldValue * The existing value.
Returns:
true if the values are different. {Boolean}

Type Definitions

instance.validationFunction

Signature of the function used to validate new input. It accepts a newValue and an oldValue which are used to determine if the newValue is valid.
Parameters:
Name Type Description
newValue * The new value to validate.
oldValue * The existing value.
Returns:
true if the validation succeeded, otherwise false. {Boolean}