object
ObjectSchema (object
value, object
options[, boolean
throwError])
This param only accept object
as data type and this is a original value to evaluate.
this param need a object
with rules, and this use the next schema:
{
PROPERTY : OPTIONS
}
This param is optional, and only accept boolean. If you set it as true
then this function force throw new Error
and you will need use try {} catch {}
.
- [string] type
- [boolean] nullable
- [any] defaultValue
####### Available data types
- Only array:
array
or[]
- Array, null or object:
object
- PLain object:
{}
,plainObject
- integer :
integer
- float:
float
- number(float, integer):
numeric
,number
- string :
string
ObjectSchema({name : "John Smith", age : 22, data : {}}, {
name : {type : "string"},
age : {type: "number", nullable : true, defaultValue : 1},
data : { type :"plainObject"}
}, true); // return {name : "john Smith", age : 22, data : {}}
ObjectSchema({name : "john Smith", age : 22, data : {}}, {
name : {type : "string"},
age : {type: "float", nullable : true, defaultValue : 1},
data : { type :"plainObject"}
}, true); // given error
ObjectSchema({name : "john Smith", age : 22, data : {}}, {
name : {type : "string"},
age : {type: "float", nullable : true, defaultValue : 1},
data : { type :"plainObject"}
}); // return {name : "john Smith", data : {}}
ObjectSchema({name : "john Smith", age : 22, data : []}, {
name : {type : "string"},
age : {type: "float", nullable : true, defaultValue : 1},
data : { type :"object"}
}); // return {name : "john Smith", data : []}
ObjectSchema({name : "john Smith", age : 22, data : []}, {
name : {type : "string"},
age : {type: "float", nullable : true, defaultValue : 1},
data : { type :"array"}
}); // return {name : "john Smith", data : []}