Reference Source
public class | source

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:

NameTypeAttributeDescription
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'});

public valueMustChange(newValue: *, oldValue: *): Boolean source

Ensures that the value has changed.

Params:

NameTypeAttributeDescription
newValue *

The new value.

oldValue *

The existing value.

Return:

Boolean

true if the values are different.