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

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

All files » .readme/includes/Schema/ » SchemaAnyExample.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  1   1             1 1       1 1       1   1        
 
var Schema = Divhide.Schema;
 
var schema = Schema
            .any()
            .required()
            .compile();
 
 
/// valid string value!
var value = schema.value("str");
expect(value).equals(value);
 
 
/// valid array value!
value = schema.value([1,2]);
expect(value).equals([1,2]);
 
 
/// because its required it fails
expect(
    function(){
        schema.value(null);
    })
    .toThrow(
        new Error("Value is required.")
    );