async-validator
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -919,2 +919,28 @@ 'use strict'; | ||
/** | ||
* Performs validation for any type. | ||
* | ||
* @param rule The validation rule. | ||
* @param value The value of the field on the source object. | ||
* @param callback The callback function. | ||
* @param source The source object being validated. | ||
* @param options The validation options. | ||
* @param options.messages The validation messages. | ||
*/ | ||
function any(rule, value, callback, source, options) { | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
if (validate) { | ||
if (isEmptyValue(value) && !rule.required) { | ||
return callback(); | ||
} | ||
rules.required(rule, value, source, errors, options); | ||
} | ||
callback(errors); | ||
} | ||
var validators = { | ||
@@ -936,3 +962,4 @@ string: string, | ||
email: type$1, | ||
required: required$1 | ||
required: required$1, | ||
any: any | ||
}; | ||
@@ -939,0 +966,0 @@ |
@@ -38,3 +38,4 @@ // Type definitions for async-validator 3.0.4 | ||
| 'hex' | ||
| 'email'; | ||
| 'email' | ||
| 'any'; | ||
@@ -41,0 +42,0 @@ interface RuleItem { |
@@ -914,2 +914,28 @@ function _extends() { | ||
/** | ||
* Performs validation for any type. | ||
* | ||
* @param rule The validation rule. | ||
* @param value The value of the field on the source object. | ||
* @param callback The callback function. | ||
* @param source The source object being validated. | ||
* @param options The validation options. | ||
* @param options.messages The validation messages. | ||
*/ | ||
function any(rule, value, callback, source, options) { | ||
var errors = []; | ||
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); | ||
if (validate) { | ||
if (isEmptyValue(value) && !rule.required) { | ||
return callback(); | ||
} | ||
rules.required(rule, value, source, errors, options); | ||
} | ||
callback(errors); | ||
} | ||
var validators = { | ||
@@ -931,3 +957,4 @@ string: string, | ||
email: type$1, | ||
required: required$1 | ||
required: required$1, | ||
any: any | ||
}; | ||
@@ -934,0 +961,0 @@ |
{ | ||
"name": "async-validator", | ||
"description": "validate form asynchronous", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "files": [ |
@@ -174,2 +174,3 @@ # async-validator | ||
* `email`: Must be of type `email`. | ||
* `any`: Can be any type. | ||
@@ -176,0 +177,0 @@ #### Required |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
240835
2338
455