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

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

All files » .readme/includes/Schema/ » SchemaStringExample.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  1   1                         1     1           1          
 
var Schema = Divhide.Schema;
 
var serialized =
        Schema.object({
            "name"      : "",
            "friends"   : Schema.array([
                {
                    name: ""
                }
            ]).optional(),
        })
        .required()
        .serialize();
 
/// deserialize the object
var schema = Schema.deserialize(serialized);
 
/// let's get the object
var value = schema.value({
    id: 1,
    name: "Oscar",
    friends: [{ name: "Solange" }]
});
 
expect(value).equals({
    name: "Oscar",
    friends: [{ name: "Solange" }]
});