Skip to content

Commit 05554df

Browse files
committed
Do not test for null in required plugin.
Comment out corresponding test spec.
1 parent cbfcfc7 commit 05554df

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

plugin/util/required.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = function() {
77
if(!this.isRoot()
88
&& this.rule.required
99
&& (!this.source.hasOwnProperty(this.field)
10-
|| this.value === undefined || this.value === null)) {
10+
|| this.value === undefined)) {
1111
this.raise(
1212
this.reasons.required,
1313
this.messages.required, this.field);

test/spec/string.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ describe('async-validate:', function() {
1919
});
2020
});
2121

22-
it('should error on required string field (null)', function(done) {
23-
var descriptor = {
24-
type: 'object',
25-
fields: {
26-
name: {type: 'string', required: true}
27-
}
28-
}
29-
var schema = new Schema(descriptor);
30-
schema.validate({name: null}, function(err, res) {
31-
expect(res.errors.length).to.eql(2);
32-
expect(res.fields.name.length).to.eql(2);
33-
expect(res.errors[0].message).to.eql('name is required');
34-
done();
35-
});
36-
});
22+
//it('should error on required string field (null)', function(done) {
23+
//var descriptor = {
24+
//type: 'object',
25+
//fields: {
26+
//name: {type: 'string', required: true}
27+
//}
28+
//}
29+
//var schema = new Schema(descriptor);
30+
//schema.validate({name: null}, function(err, res) {
31+
//expect(res.errors.length).to.eql(2);
32+
//expect(res.fields.name.length).to.eql(2);
33+
//expect(res.errors[0].message).to.eql('name is required');
34+
//done();
35+
//});
36+
//});
3737

3838
it('should error on non-string type', function(done) {
3939
var descriptor = {

0 commit comments

Comments
 (0)