Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@rc-component/async-validator

Package Overview
Dependencies
Maintainers
5
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rc-component/async-validator - npm Package Compare versions

Comparing version
5.0.4
to
5.1.0
+2
-1
es/index.d.ts

@@ -29,2 +29,3 @@ import type { InternalRuleItem, InternalValidateMessages, RuleItem, RuleType, Rules, SyncErrorType, ValidateCallback, ValidateMessages, ValidateOption, Values } from './interface';

email: import("./interface").ExecuteValidator;
tel: import("./interface").ExecuteValidator;
required: import("./interface").ExecuteValidator;

@@ -42,4 +43,4 @@ any: import("./interface").ExecuteValidator;

getType(rule: InternalRuleItem): RuleType;
getValidationMethod(rule: InternalRuleItem): import("./interface").ExecuteValidator | ((rule: InternalRuleItem, value: any, callback: (error?: string | Error) => void, source: Values, options: ValidateOption) => void | import("./interface").SyncValidateResult);
getValidationMethod(rule: InternalRuleItem): ((rule: InternalRuleItem, value: any, callback: (error?: string | Error) => void, source: Values, options: ValidateOption) => void | import("./interface").SyncValidateResult) | import("./interface").ExecuteValidator;
}
export default Schema;

@@ -159,3 +159,3 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";

}
if (errorList.length && rule.message !== undefined) {
if (errorList.length && rule.message !== undefined && rule.message !== null) {
errorList = [].concat(rule.message);

@@ -162,0 +162,0 @@ }

@@ -1,2 +0,2 @@

export type RuleType = 'string' | 'number' | 'boolean' | 'method' | 'regexp' | 'integer' | 'float' | 'array' | 'object' | 'enum' | 'date' | 'url' | 'hex' | 'email' | 'pattern' | 'any';
export type RuleType = 'string' | 'number' | 'boolean' | 'method' | 'regexp' | 'integer' | 'float' | 'array' | 'object' | 'enum' | 'date' | 'url' | 'hex' | 'email' | 'tel' | 'pattern' | 'any';
export interface ValidateOption {

@@ -86,2 +86,3 @@ suppressWarning?: boolean;

email?: ValidateMessage<[FullField, Type]>;
tel?: ValidateMessage<[FullField, Type]>;
url?: ValidateMessage<[FullField, Type]>;

@@ -88,0 +89,0 @@ hex?: ValidateMessage<[FullField, Type]>;

@@ -24,2 +24,3 @@ export function newMessages() {

email: '%s is not a valid %s',
tel: '%s is not a valid %s',
url: '%s is not a valid %s',

@@ -26,0 +27,0 @@ hex: '%s is not a valid %s'

declare const _default: {
required: import("..").ExecuteRule;
whitespace: import("..").ExecuteRule;
type: import("..").ExecuteRule;
range: import("..").ExecuteRule;
enum: import("..").ExecuteRule;
pattern: import("..").ExecuteRule;
required: import("../interface").ExecuteRule;
whitespace: import("../interface").ExecuteRule;
type: import("../interface").ExecuteRule;
range: import("../interface").ExecuteRule;
enum: import("../interface").ExecuteRule;
pattern: import("../interface").ExecuteRule;
};
export default _default;

@@ -14,2 +14,9 @@ import _typeof from "@babel/runtime/helpers/esm/typeof";

// ),
/**
* Phone number regex, support country code, brackets, spaces, and dashes (or non-breaking hyphen \u2011).
* @see https://regexr.com/3c53v
* @see https://ihateregex.io/expr/phone/
* @see https://developers.google.com/style/phone-numbers using non-breaking hyphen \u2011
*/
tel: /^(\+[0-9]{1,3}[-\s\u2011]?)?(\([0-9]{1,4}\)[-\s\u2011]?)?([0-9]+[-\s\u2011]?)*[0-9]+$/,
hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i

@@ -55,2 +62,5 @@ };

},
tel: function tel(value) {
return typeof value === 'string' && value.length <= 32 && !!value.match(pattern.tel);
},
url: function url(value) {

@@ -68,3 +78,3 @@ return typeof value === 'string' && value.length <= 2048 && !!value.match(getUrlRegex());

}
var custom = ['integer', 'float', 'array', 'regexp', 'object', 'method', 'email', 'number', 'date', 'url', 'hex'];
var custom = ['integer', 'float', 'array', 'regexp', 'object', 'method', 'email', 'tel', 'number', 'date', 'url', 'hex'];
var ruleType = rule.type;

@@ -71,0 +81,0 @@ if (custom.indexOf(ruleType) > -1) {

@@ -77,3 +77,3 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";

function isNativeStringType(type) {
return type === 'string' || type === 'url' || type === 'hex' || type === 'email' || type === 'date' || type === 'pattern';
return type === 'string' || type === 'url' || type === 'hex' || type === 'email' || type === 'date' || type === 'pattern' || type === 'tel';
}

@@ -80,0 +80,0 @@ export function isEmptyValue(value, type) {

declare const _default: {
string: import("..").ExecuteValidator;
method: import("..").ExecuteValidator;
number: import("..").ExecuteValidator;
boolean: import("..").ExecuteValidator;
regexp: import("..").ExecuteValidator;
integer: import("..").ExecuteValidator;
float: import("..").ExecuteValidator;
array: import("..").ExecuteValidator;
object: import("..").ExecuteValidator;
enum: import("..").ExecuteValidator;
pattern: import("..").ExecuteValidator;
date: import("..").ExecuteValidator;
url: import("..").ExecuteValidator;
hex: import("..").ExecuteValidator;
email: import("..").ExecuteValidator;
required: import("..").ExecuteValidator;
any: import("..").ExecuteValidator;
string: import("../interface").ExecuteValidator;
method: import("../interface").ExecuteValidator;
number: import("../interface").ExecuteValidator;
boolean: import("../interface").ExecuteValidator;
regexp: import("../interface").ExecuteValidator;
integer: import("../interface").ExecuteValidator;
float: import("../interface").ExecuteValidator;
array: import("../interface").ExecuteValidator;
object: import("../interface").ExecuteValidator;
enum: import("../interface").ExecuteValidator;
pattern: import("../interface").ExecuteValidator;
date: import("../interface").ExecuteValidator;
url: import("../interface").ExecuteValidator;
hex: import("../interface").ExecuteValidator;
email: import("../interface").ExecuteValidator;
tel: import("../interface").ExecuteValidator;
required: import("../interface").ExecuteValidator;
any: import("../interface").ExecuteValidator;
};
export default _default;

@@ -32,4 +32,5 @@ import any from "./any";

email: type,
tel: type,
required: required,
any: any
};

@@ -29,2 +29,3 @@ import type { InternalRuleItem, InternalValidateMessages, RuleItem, RuleType, Rules, SyncErrorType, ValidateCallback, ValidateMessages, ValidateOption, Values } from './interface';

email: import("./interface").ExecuteValidator;
tel: import("./interface").ExecuteValidator;
required: import("./interface").ExecuteValidator;

@@ -42,4 +43,4 @@ any: import("./interface").ExecuteValidator;

getType(rule: InternalRuleItem): RuleType;
getValidationMethod(rule: InternalRuleItem): import("./interface").ExecuteValidator | ((rule: InternalRuleItem, value: any, callback: (error?: string | Error) => void, source: Values, options: ValidateOption) => void | import("./interface").SyncValidateResult);
getValidationMethod(rule: InternalRuleItem): ((rule: InternalRuleItem, value: any, callback: (error?: string | Error) => void, source: Values, options: ValidateOption) => void | import("./interface").SyncValidateResult) | import("./interface").ExecuteValidator;
}
export default Schema;

@@ -177,3 +177,3 @@ "use strict";

}
if (errorList.length && rule.message !== undefined) {
if (errorList.length && rule.message !== undefined && rule.message !== null) {
errorList = [].concat(rule.message);

@@ -180,0 +180,0 @@ }

@@ -1,2 +0,2 @@

export type RuleType = 'string' | 'number' | 'boolean' | 'method' | 'regexp' | 'integer' | 'float' | 'array' | 'object' | 'enum' | 'date' | 'url' | 'hex' | 'email' | 'pattern' | 'any';
export type RuleType = 'string' | 'number' | 'boolean' | 'method' | 'regexp' | 'integer' | 'float' | 'array' | 'object' | 'enum' | 'date' | 'url' | 'hex' | 'email' | 'tel' | 'pattern' | 'any';
export interface ValidateOption {

@@ -86,2 +86,3 @@ suppressWarning?: boolean;

email?: ValidateMessage<[FullField, Type]>;
tel?: ValidateMessage<[FullField, Type]>;
url?: ValidateMessage<[FullField, Type]>;

@@ -88,0 +89,0 @@ hex?: ValidateMessage<[FullField, Type]>;

@@ -31,2 +31,3 @@ "use strict";

email: '%s is not a valid %s',
tel: '%s is not a valid %s',
url: '%s is not a valid %s',

@@ -33,0 +34,0 @@ hex: '%s is not a valid %s'

declare const _default: {
required: import("..").ExecuteRule;
whitespace: import("..").ExecuteRule;
type: import("..").ExecuteRule;
range: import("..").ExecuteRule;
enum: import("..").ExecuteRule;
pattern: import("..").ExecuteRule;
required: import("../interface").ExecuteRule;
whitespace: import("../interface").ExecuteRule;
type: import("../interface").ExecuteRule;
range: import("../interface").ExecuteRule;
enum: import("../interface").ExecuteRule;
pattern: import("../interface").ExecuteRule;
};
export default _default;

@@ -21,2 +21,9 @@ "use strict";

// ),
/**
* Phone number regex, support country code, brackets, spaces, and dashes (or non-breaking hyphen \u2011).
* @see https://regexr.com/3c53v
* @see https://ihateregex.io/expr/phone/
* @see https://developers.google.com/style/phone-numbers using non-breaking hyphen \u2011
*/
tel: /^(\+[0-9]{1,3}[-\s\u2011]?)?(\([0-9]{1,4}\)[-\s\u2011]?)?([0-9]+[-\s\u2011]?)*[0-9]+$/,
hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i

@@ -62,2 +69,5 @@ };

},
tel: function tel(value) {
return typeof value === 'string' && value.length <= 32 && !!value.match(pattern.tel);
},
url: function url(value) {

@@ -75,3 +85,3 @@ return typeof value === 'string' && value.length <= 2048 && !!value.match((0, _url.default)());

}
var custom = ['integer', 'float', 'array', 'regexp', 'object', 'method', 'email', 'number', 'date', 'url', 'hex'];
var custom = ['integer', 'float', 'array', 'regexp', 'object', 'method', 'email', 'tel', 'number', 'date', 'url', 'hex'];
var ruleType = rule.type;

@@ -78,0 +88,0 @@ if (custom.indexOf(ruleType) > -1) {

@@ -92,3 +92,3 @@ "use strict";

function isNativeStringType(type) {
return type === 'string' || type === 'url' || type === 'hex' || type === 'email' || type === 'date' || type === 'pattern';
return type === 'string' || type === 'url' || type === 'hex' || type === 'email' || type === 'date' || type === 'pattern' || type === 'tel';
}

@@ -95,0 +95,0 @@ function isEmptyValue(value, type) {

declare const _default: {
string: import("..").ExecuteValidator;
method: import("..").ExecuteValidator;
number: import("..").ExecuteValidator;
boolean: import("..").ExecuteValidator;
regexp: import("..").ExecuteValidator;
integer: import("..").ExecuteValidator;
float: import("..").ExecuteValidator;
array: import("..").ExecuteValidator;
object: import("..").ExecuteValidator;
enum: import("..").ExecuteValidator;
pattern: import("..").ExecuteValidator;
date: import("..").ExecuteValidator;
url: import("..").ExecuteValidator;
hex: import("..").ExecuteValidator;
email: import("..").ExecuteValidator;
required: import("..").ExecuteValidator;
any: import("..").ExecuteValidator;
string: import("../interface").ExecuteValidator;
method: import("../interface").ExecuteValidator;
number: import("../interface").ExecuteValidator;
boolean: import("../interface").ExecuteValidator;
regexp: import("../interface").ExecuteValidator;
integer: import("../interface").ExecuteValidator;
float: import("../interface").ExecuteValidator;
array: import("../interface").ExecuteValidator;
object: import("../interface").ExecuteValidator;
enum: import("../interface").ExecuteValidator;
pattern: import("../interface").ExecuteValidator;
date: import("../interface").ExecuteValidator;
url: import("../interface").ExecuteValidator;
hex: import("../interface").ExecuteValidator;
email: import("../interface").ExecuteValidator;
tel: import("../interface").ExecuteValidator;
required: import("../interface").ExecuteValidator;
any: import("../interface").ExecuteValidator;
};
export default _default;

@@ -39,4 +39,5 @@ "use strict";

email: _type.default,
tel: _type.default,
required: _required.default,
any: _any.default
};
{
"name": "@rc-component/async-validator",
"version": "5.0.4",
"version": "5.1.0",
"description": "Validate form asynchronous",

@@ -5,0 +5,0 @@ "keywords": [

@@ -186,2 +186,3 @@ # @rc-component/async-validator

- `email`: Must be of type `email`.
- `tel`: Must be of type `tel`.
- `any`: Can be any type.

@@ -188,0 +189,0 @@