conformation
Advanced tools
Comparing version 0.9.0 to 0.10.0
@@ -97,7 +97,7 @@ 'use strict'; | ||
function requiredRule(value) { | ||
if (_lodash2.default.isNil(value) || value === '') { | ||
function requiredRule(value, params, ctx) { | ||
if (ctx.skipRequired || !(_lodash2.default.isNil(value) || value === '')) { | ||
return { valid: true }; | ||
} else { | ||
return (0, _util.error)('required'); | ||
} else { | ||
return { valid: true }; | ||
} | ||
@@ -104,0 +104,0 @@ } |
{ | ||
"name": "conformation", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"description": "Yet another object validator", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -139,2 +139,7 @@ | ||
it('should allow required() to be skipped', function () { | ||
let schema = Schema.any().required(); | ||
expect(schema.validate('', {skipRequired: true}).valid).to.be.true; | ||
}); | ||
it('should have a only() rule', function () { | ||
@@ -141,0 +146,0 @@ let schema = Schema.any().only(1, 2); |
27441
754