Validation
You can directly use an instance of this class.
validate
Set of property value validation functions.
Method Summary
Public Methods | ||
public |
enumeration(enumeration: Object): ValidationFunction Ensures that the new value is within the enumeration. |
|
public |
valueMustChange(newValue: *, oldValue: *): Boolean Ensures that the value has changed. |
Public Methods
public enumeration(enumeration: Object): ValidationFunction source
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.
Params:
Name | Type | Attribute | Description |
enumeration | Object | Object that represents an enum. |
Return:
ValidationFunction | a validation function that ensures that the given value is within the enumeration. |
Example:
// 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'});