getSchema
Returns the schema for a type or value.
getSchema(valueOrType)
Calls the @can.getSchema
property on the valueOrType
argument. If it's not available and
valueOrType
has a constructor
property, calls the constructor[@can.getSchema]
and returns the result.
import canReflect from "can-reflect";
var Type = DefineMap.extend({
name: "string",
id: "number"
});
canReflect.getSchema( Type ) //-> {
// type: "map",
// keys: {
// name: MaybeString
// id: MaybeNumber
// }
// }
Parameters
- valueOrType
{Object|function}
:A value, constructor function, or class to get the schema from.
Returns
{Object}
:
A schema. A schema for a isMapLike looks like:
{
type: "map",
identity: ["id"],
keys: {
id: Number,
name: String,
complete: Boolean,
owner: User
}
}
A schema for a list looks like:
{
type: "list",
values: String
keys: {
count: Number
}
}