async-validator
Advanced tools
Comparing version 1.4.1 to 1.4.2
@@ -50,2 +50,6 @@ 'use strict'; | ||
function isNativeStringType(type) { | ||
return type === 'string' || type === 'url' || type === 'hex' || type === 'email'; | ||
} | ||
function isEmptyValue(value, type) { | ||
@@ -58,3 +62,3 @@ if (value === undefined || value === null) { | ||
} | ||
if (type === 'string' && typeof value === 'string' && !value) { | ||
if (isNativeStringType(type) && typeof value === 'string' && !value) { | ||
return true; | ||
@@ -61,0 +65,0 @@ } |
@@ -13,5 +13,17 @@ 'use strict'; | ||
var _util = require('../util'); | ||
function type(rule, value, callback, source, options) { | ||
var ruleType = rule.type; | ||
var errors = []; | ||
_rule2['default'].type(rule, value, source, errors, options); | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
if (validate) { | ||
if ((0, _util.isEmptyValue)(value, ruleType) && !rule.required) { | ||
return callback(); | ||
} | ||
_rule2['default'].required(rule, value, source, errors, options, ruleType); | ||
if (!(0, _util.isEmptyValue)(value, ruleType)) { | ||
_rule2['default'].type(rule, value, source, errors, options); | ||
} | ||
} | ||
callback(errors); | ||
@@ -18,0 +30,0 @@ } |
{ | ||
"name": "async-validator", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"description": "validate form asynchronous", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51697
1104