Coral.transform is a set of property value transformation functions for use in Coral components.

Coral.transform API

Property value transform functions.

Methods

Coral.transform.boolean

Transform the provided value into a boolean. Follows the behavior of JavaScript thruty/falsy.
Parameters:
Name Type Description
value * The value to convert to Boolean.
Returns:
The corresponding boolean value. {Boolean}

Coral.transform.booleanAttr

Transform the provided value into a boolean. Follows the behavior of the HTML specification, in which the existence of the attribute indicates true regardless of the attribute's value.
Parameters:
Name Type Description
value * The value to convert to Boolean.
Returns:
The corresponding boolean value. {Boolean}

Coral.transform.float

Transforms the provided value into a floating number. The conversion is strict in the sense that if non numeric values are detected, null is returned instead.
Parameters:
Name Type Description
value * The value to be converted to a Number.

Coral.transform.number

Transforms the provided value into a floating point number.
Parameters:
Name Type Description
value * The value to convert to a Number.
Returns:
The corresponding number or null if the passed value cannot be converted to a number. {Number}

Coral.transform.string

Transform the provided value into a string. When given null or undefined it will be converted to an empty string("").
Parameters:
Name Type Description
value * The value to convert to String.
Returns:
The corresponding string value. {String}