Code coverage report for .readme/includes/Schema/SchemaObjectExample.js

Statements: 100% (4 / 4)      Branches: 100% (0 / 0)      Functions: 100% (0 / 0)      Lines: 100% (4 / 4)      Ignored: none     

All files » .readme/includes/Schema/ » SchemaObjectExample.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34  1   1                       1                     1              
 
var Schema = Divhide.Schema;
 
var schema =
        Schema.object({
            "/^optional/"   : Schema.string().optional(),
            "number"        : 0,
            "string"        : "",
        })
        .required()
        /// TIP: When compiled the schema is faster
        .compile();
 
 
/// let's get the object
var value = schema.value({
    string      : "awesome!",
    number      : "0",
    optional1   : "1",
    optional2   : "2",
    other       : 1
});
 
 
/// Please notice that some of the object properties were
/// not included!
expect(value).equals({
    "number": 0,
    "string": "awesome!",
    "optional1": "1",
    "optional2": "2"
});