Reference Source
public class | source

Transformation

You can directly use an instance of this class. transform

Set of property value transformation functions.

Method Summary

Public Methods
public

boolean(value: *): Boolean

Transform the provided value into a boolean.

public

booleanAttr(value: *): Boolean

Transform the provided value into a boolean.

public

float(value: *): *

Transforms the provided value into a floating number.

public

number(value: *): Number

Transforms the provided value into a floating point number.

public

string(value: *): String

Transform the provided value into a string.

Public Methods

public boolean(value: *): Boolean source

Transform the provided value into a boolean. Follows the behavior of JavaScript thruty/falsy.

Params:

NameTypeAttributeDescription
value *

The value to convert to Boolean.

Return:

Boolean

The corresponding boolean value.

public booleanAttr(value: *): Boolean source

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. If the value is a boolean, it ignores the transformation.

Params:

NameTypeAttributeDescription
value *

The value to convert to Boolean.

Return:

Boolean

The corresponding boolean value.

public float(value: *): * source

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.

Params:

NameTypeAttributeDescription
value *

The value to be converted to a Number.

Return:

*

public number(value: *): Number source

Transforms the provided value into a floating point number.

Params:

NameTypeAttributeDescription
value *

The value to convert to a Number.

Return:

Number (nullable: true)

The corresponding number or null if the passed value cannot be converted to a number.

public string(value: *): String source

Transform the provided value into a string. When given null or undefined it will be converted to an empty string("").

Params:

NameTypeAttributeDescription
value *

The value to convert to String.

Return:

String

The corresponding string value.