1 |
|
2 |
|
3 |
|
4 |
|
5 | var _ = require('lodash'),
|
6 | SchemaType = require('../schematype');
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | var SchemaObject = module.exports = function(options){
|
16 | options = options || {};
|
17 |
|
18 | SchemaType.call(this, options);
|
19 |
|
20 | if (options.hasOwnProperty('default')){
|
21 | var defaults = options.default,
|
22 | fn = typeof defaults === 'function';
|
23 | }
|
24 |
|
25 | this.default = function(){
|
26 | return fn ? defaults() : defaults || {};
|
27 | };
|
28 | };
|
29 |
|
30 | SchemaObject.__proto__ = SchemaType;
|
31 | SchemaObject.type = SchemaObject.prototype.type = Object;
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | SchemaObject.prototype.__proto__ = SchemaType.prototype;
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 | SchemaObject.prototype.compare = function(data, value){
|
49 | return JSON.stringify(data) === JSON.stringify(value);
|
50 | }; |
\ | No newline at end of file |