Type
Provides a constructor function to be used to convert any set value into an appropriate value.
Type
A constructor function can be provided that is called to convert incoming values set on this property, like:
{
prop: {
Type: Person
}
}
Type
is called before type and before set. It checks if the incoming value
is an instanceof Type
. If it is, or if it is null
or undefined
, it passes the original value through. If not, it passes the original value to new Type(originalValue)
and returns the
new instance to be set.
{propDefinition}
A PropDefinition that defines an inline can-define/map/map type. For example:
{
address: {
Type: {
street: "string",
city: "string"
}
}
}
[Type|propDefinition]
Defines an inline can-define/list/list type that's an array of Type
or inline propDefinition
can-define/map/map
instances. For example:
{
people: {
Type: [ Person ]
},
addresses: {
Type: [ {
street: "string",
city: "string"
} ]
}
}
Use
const Address = DefineMap.extend( {
street: "string",
city: "string"
} );
const Direction = DefineMap.extend( {
from: { Type: Address },
to: Address
} );
const direction = new Direction( {
from: { street: "2060 N. Stave", city: "Chicago" },
to: new Address( { street: "123 Greenview", city: "Libertyville" } )
} );