Property value validators
Methods
-
Coral.validate.enumeration
-
- 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
-
- Parameters:
-
Name Type Description newValue * The new value. oldValue * The existing value. - Returns:
-
true
if the values are different. {Boolean}
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.
Ensures that the value has changed.
Type Definitions
-
instance.validationFunction
-
- Parameters:
-
Name Type Description newValue * The new value to validate. oldValue * The existing value. - Returns:
-
true
if the validation succeeded, otherwisefalse
. {Boolean}
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.