Skip to content

Commit

Permalink
add strict option for test
Browse files Browse the repository at this point in the history
  • Loading branch information
aliaksandr-master committed Jan 11, 2015
1 parent a6b81db commit b826c00
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion tests/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ exports['validate value-array'] = {
})
};

var s2 = new Schema().array(function (required, optional) {
var s2 = new Schema().strict().array(function (required, optional) {
required('age');
optional('school_names');
});
Expand Down
5 changes: 3 additions & 2 deletions tests/examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ exports['Simple Usage'] = {
});
},
'verify - excess field' : function (test) {
var sh1 = new Schema().object(function () {
console.log(123);
var sh1 = new Schema().strict().object(function () {
this.field('first_name');
this.required('last_name');
this.optional('middle_name');
Expand All @@ -94,7 +95,7 @@ exports['Simple Usage'] = {
var _keys = _.keys(value);
value.excess_field = true;

sh1.verifier().verify(value, function (err) {
sh1.verify(value, function (err) {
test.ok(!!err);
test.equal(err.rule, 'available_fields');
test.deepEqual(err.params, _keys);
Expand Down
12 changes: 7 additions & 5 deletions tests/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ exports.schema = {
}
};

var s1 = new Schema().object(function (required, optional) {
var s1 = new Schema().strict().object(function (required, optional) {
required('age');
optional('school_names');
});

var s2 = new Schema().object(function (required, optional) {
required('age');
optional('school_names');
});
Expand Down Expand Up @@ -178,11 +183,8 @@ exports['validate object'] = {
}),

'#12-ignore': tester({
schema: s1,
schema: s2,
expect: true,
options: {
ignoreExcess: true
},
value: {
'age': {
'asdasdasd': 'asdasdasd'
Expand Down

0 comments on commit b826c00

Please sign in to comment.