Class: _DTOInstance

DTO~ _DTOInstance

new _DTOInstance()

DTOInstance And instance of the defined DTO
Source:

Members

(inner) _values

The actual values of the instance
Source:

Methods

(inner) $create(obj)

Creates a new DTO instance from the supplied JSON object.
Parameters:
Name Type Description
obj object A JSON object return {object} A JSON Object.
Source:

(inner) $defaults(obj)

Runs the provided data through the DTO applying the defaults. If the JSON object supplied has values for the defaults the defaults will not overwrite the existing values. Does not manipulate the instance itself.
Parameters:
Name Type Description
obj object A JSON object
Source:

(inner) $init()

Initializes the instance _values with defaults
Source:

(inner) $startNewInstance()

Initializes _values to {}
Source:

(inner) $test(obj) → {object}

Tests if the JSON object is valid for the DTO. Returns an exception if unable to conver the JSON object to a DTO or null if no problems are found.
Parameters:
Name Type Description
obj object The JSON Objecct
Source:
Returns:
The exception (or null)
Type
object

(inner) _get() → {object}

Gets the _values
Source:
Returns:
The JSON object of the instance
Type
object

(inner) _getDefValue(key) → {string}

Gets the default value of the supplied key
Parameters:
Name Type Description
key string The key
Source:
Returns:
The default value (or undefined)
Type
string

(inner) _normalizeType(key, value) → {mixed}

Attempts to normalize the value to the correct type. Ex: If Age is an int and '30' is supplied it will be converted to the int value 30. If the value can be normalized the normalized value is return. Otherwise the original value is returned.
Parameters:
Name Type Description
key string The key of the value
value string The value you want to normalize
Source:
Returns:
The normalized value
Type
mixed

(inner) _set(key, value)

Sets a key of the instance to value
Parameters:
Name Type Description
key string The key of the instance to set
value string The value of the key
Source: