co.validation 2.7.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/createValidation.d.ts +6 -0
- package/lib/createValidation.d.ts.map +1 -0
- package/lib/createValidation.js +153 -204
- package/lib/createValidation.js.map +1 -0
- package/lib/helpers.d.ts +2 -0
- package/lib/helpers.d.ts.map +1 -0
- package/lib/helpers.js +4 -8
- package/lib/helpers.js.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +18 -38
- package/lib/index.js.map +1 -0
- package/lib/messageProcessor.d.ts +7 -0
- package/lib/messageProcessor.d.ts.map +1 -0
- package/lib/messageProcessor.js +45 -51
- package/lib/messageProcessor.js.map +1 -0
- package/lib/operators.d.ts +4 -0
- package/lib/operators.d.ts.map +1 -0
- package/lib/operators.js +60 -71
- package/lib/operators.js.map +1 -0
- package/lib/types.d.ts +123 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +3 -0
- package/lib/types.js.map +1 -0
- package/lib/validators.d.ts +18 -0
- package/lib/validators.d.ts.map +1 -0
- package/lib/validators.js +164 -196
- package/lib/validators.js.map +1 -0
- package/package.json +13 -21
- package/tsconfig.json +32 -0
- package/lib/__tests__/component.arrayValidation.js +0 -201
- package/lib/__tests__/component.objectValidation.js +0 -556
- package/lib/__tests__/component.reduxFormValidation.js +0 -20
- package/lib/__tests__/component.valueValidation.js +0 -923
- package/lib/__tests__/integration.objectValidation.js +0 -64
- package/lib/__tests__/integration.registrationForm.js +0 -234
- package/lib/__tests__/integration.valueValidation.js +0 -448
- package/lib/__tests__/operators.js +0 -28
- package/lib/__tests__/unit.operators.js +0 -125
- package/lib/createObjectValidation.js +0 -34
- package/lib/createValueValidation.js +0 -71
package/lib/operators.js
CHANGED
|
@@ -1,82 +1,71 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.all = exports.oneOf = void 0;
|
|
7
|
-
|
|
8
4
|
const oneOf = (...validators) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return (value, allValues) => {
|
|
14
|
-
const validationErrors = [];
|
|
15
|
-
|
|
16
|
-
for (const validator of validators) {
|
|
17
|
-
let currentResult = validator(value, allValues);
|
|
18
|
-
|
|
19
|
-
if (currentResult.errors) {
|
|
20
|
-
if (Array.isArray(currentResult.errors)) {
|
|
21
|
-
validationErrors.push(...currentResult.errors);
|
|
22
|
-
} else {
|
|
23
|
-
validationErrors.push(currentResult.errors);
|
|
24
|
-
}
|
|
25
|
-
} else {
|
|
26
|
-
return currentResult;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (validationErrors && validationErrors.length > 0) {
|
|
31
|
-
return {
|
|
32
|
-
data: undefined,
|
|
33
|
-
errors: validationErrors
|
|
34
|
-
};
|
|
5
|
+
if (validators.length === 0) {
|
|
6
|
+
throw new Error('You must provide at least one validator');
|
|
35
7
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
8
|
+
return (value, allValues) => {
|
|
9
|
+
const validationErrors = [];
|
|
10
|
+
for (const validator of validators) {
|
|
11
|
+
const currentResult = validator(value, allValues);
|
|
12
|
+
if (currentResult.errors) {
|
|
13
|
+
if (Array.isArray(currentResult.errors)) {
|
|
14
|
+
validationErrors.push(...currentResult.errors);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
validationErrors.push(currentResult.errors);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
return currentResult;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (validationErrors && validationErrors.length > 0) {
|
|
25
|
+
return {
|
|
26
|
+
data: undefined,
|
|
27
|
+
errors: validationErrors,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
data: value,
|
|
32
|
+
errors: undefined,
|
|
33
|
+
};
|
|
40
34
|
};
|
|
41
|
-
};
|
|
42
35
|
};
|
|
43
|
-
|
|
44
36
|
exports.oneOf = oneOf;
|
|
45
|
-
|
|
46
37
|
const all = (...validators) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return (value, allValues) => {
|
|
52
|
-
const validationErrors = validators.reduce((validationErrors, validator) => {
|
|
53
|
-
const currentResult = validator(value, allValues);
|
|
54
|
-
|
|
55
|
-
if (currentResult.errors) {
|
|
56
|
-
if (Array.isArray(currentResult.errors)) {
|
|
57
|
-
validationErrors.push(...currentResult.errors);
|
|
58
|
-
} else {
|
|
59
|
-
validationErrors.push(currentResult.errors);
|
|
60
|
-
}
|
|
61
|
-
} else {
|
|
62
|
-
value = currentResult.data;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return validationErrors;
|
|
66
|
-
}, []);
|
|
67
|
-
|
|
68
|
-
if (validationErrors && validationErrors.length > 0) {
|
|
69
|
-
return {
|
|
70
|
-
data: undefined,
|
|
71
|
-
errors: validationErrors
|
|
72
|
-
};
|
|
38
|
+
if (validators.length === 0) {
|
|
39
|
+
throw new Error('You must provide at least one validator');
|
|
73
40
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
41
|
+
return (value, allValues) => {
|
|
42
|
+
let currentValue = value;
|
|
43
|
+
const validationErrors = [];
|
|
44
|
+
for (const validator of validators) {
|
|
45
|
+
const currentResult = validator(currentValue, allValues);
|
|
46
|
+
if (currentResult.errors) {
|
|
47
|
+
if (Array.isArray(currentResult.errors)) {
|
|
48
|
+
validationErrors.push(...currentResult.errors);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
validationErrors.push(currentResult.errors);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
currentValue = currentResult.data;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (validationErrors && validationErrors.length > 0) {
|
|
59
|
+
return {
|
|
60
|
+
data: undefined,
|
|
61
|
+
errors: validationErrors,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
data: currentValue,
|
|
66
|
+
errors: undefined,
|
|
67
|
+
};
|
|
78
68
|
};
|
|
79
|
-
};
|
|
80
69
|
};
|
|
81
|
-
|
|
82
|
-
|
|
70
|
+
exports.all = all;
|
|
71
|
+
//# sourceMappingURL=operators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operators.js","sourceRoot":"","sources":["../src/operators.ts"],"names":[],"mappings":";;;AAEO,MAAM,KAAK,GAAG,CAAC,GAAG,UAAyB,EAAe,EAAE;IACjE,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,CAAC,KAAc,EAAE,SAAmB,EAAoB,EAAE;QAC/D,MAAM,gBAAgB,GAAc,EAAE,CAAC;QACvC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,MAAM,aAAa,GAAG,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;YAClD,IAAI,aAAa,CAAC,MAAM,EAAE,CAAC;gBACzB,IAAI,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;oBACxC,gBAAgB,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;gBACjD,CAAC;qBAAM,CAAC;oBACN,gBAAgB,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;gBAC9C,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,OAAO,aAAa,CAAC;YACvB,CAAC;QACH,CAAC;QA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AC;QAED,OAAO;YACL,IAAI,EAAE,YAAY;YAClB,MAAM,EAAE,SAAS;SAClB,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC;AAlCW,QAAA,GAAG,OAkCd"}
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message getter function type - can return a string or convert an error to a message
|
|
3
|
+
*/
|
|
4
|
+
export type GetMessageFn = (...args: unknown[]) => string;
|
|
5
|
+
/**
|
|
6
|
+
* getMessage can be a function, string, or undefined
|
|
7
|
+
*/
|
|
8
|
+
export type GetMessage = GetMessageFn | string | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Validation errors can be an array of strings, or a nested object for object/array validation
|
|
11
|
+
*/
|
|
12
|
+
export type ValidationErrors = string[] | Record<string, unknown> | (unknown | null)[];
|
|
13
|
+
/**
|
|
14
|
+
* Result of a validation operation
|
|
15
|
+
*/
|
|
16
|
+
export interface ValidationResult<T = unknown> {
|
|
17
|
+
data?: T;
|
|
18
|
+
errors?: ValidationErrors;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Validator function type
|
|
22
|
+
*/
|
|
23
|
+
export type ValidatorFn<T = unknown> = (value: unknown, allValues?: unknown) => ValidationResult<T>;
|
|
24
|
+
export interface RequiredRule {
|
|
25
|
+
type: 'required';
|
|
26
|
+
getMessage?: GetMessage;
|
|
27
|
+
}
|
|
28
|
+
export interface AnyRule {
|
|
29
|
+
type: 'any';
|
|
30
|
+
}
|
|
31
|
+
export interface StringRule {
|
|
32
|
+
type: 'string';
|
|
33
|
+
getMessage?: GetMessage;
|
|
34
|
+
}
|
|
35
|
+
export interface NumberRule {
|
|
36
|
+
type: 'number';
|
|
37
|
+
getMessage?: GetMessage;
|
|
38
|
+
}
|
|
39
|
+
export interface BooleanRule {
|
|
40
|
+
type: 'boolean';
|
|
41
|
+
getMessage?: GetMessage;
|
|
42
|
+
}
|
|
43
|
+
export interface EmailRule {
|
|
44
|
+
type: 'email';
|
|
45
|
+
getMessage?: GetMessage;
|
|
46
|
+
}
|
|
47
|
+
export interface AlphanumericRule {
|
|
48
|
+
type: 'alphanumeric';
|
|
49
|
+
getMessage?: GetMessage;
|
|
50
|
+
}
|
|
51
|
+
export interface RegexRule {
|
|
52
|
+
type: 'regex';
|
|
53
|
+
regex: RegExp;
|
|
54
|
+
getMessage?: GetMessage;
|
|
55
|
+
}
|
|
56
|
+
export interface MinLengthRule {
|
|
57
|
+
type: 'minLength';
|
|
58
|
+
min: number;
|
|
59
|
+
getMessage?: GetMessage;
|
|
60
|
+
}
|
|
61
|
+
export interface MaxLengthRule {
|
|
62
|
+
type: 'maxLength';
|
|
63
|
+
max: number;
|
|
64
|
+
getMessage?: GetMessage;
|
|
65
|
+
}
|
|
66
|
+
export interface MinValueRule {
|
|
67
|
+
type: 'minValue';
|
|
68
|
+
min: number;
|
|
69
|
+
getMessage?: GetMessage;
|
|
70
|
+
}
|
|
71
|
+
export interface MaxValueRule {
|
|
72
|
+
type: 'maxValue';
|
|
73
|
+
max: number;
|
|
74
|
+
getMessage?: GetMessage;
|
|
75
|
+
}
|
|
76
|
+
export interface EqualsRule {
|
|
77
|
+
type: 'equals';
|
|
78
|
+
to: unknown;
|
|
79
|
+
getMessage?: GetMessage;
|
|
80
|
+
}
|
|
81
|
+
export interface EqualsToFieldRule {
|
|
82
|
+
type: 'equalsToField';
|
|
83
|
+
field: string;
|
|
84
|
+
getMessage?: GetMessage;
|
|
85
|
+
}
|
|
86
|
+
export interface CustomRule {
|
|
87
|
+
type: 'custom';
|
|
88
|
+
validator: (value: unknown, allValues?: unknown) => unknown;
|
|
89
|
+
getMessage?: GetMessage;
|
|
90
|
+
}
|
|
91
|
+
export interface RequiredArrayWithItemRule {
|
|
92
|
+
type: 'requiredArrayWithItem';
|
|
93
|
+
getMessage?: GetMessage;
|
|
94
|
+
}
|
|
95
|
+
export interface OneOfRule {
|
|
96
|
+
type: 'oneOf';
|
|
97
|
+
validators: ValidationRule[];
|
|
98
|
+
getMessage?: GetMessage;
|
|
99
|
+
}
|
|
100
|
+
export interface AllRule {
|
|
101
|
+
type: 'all';
|
|
102
|
+
validators: ValidationRule[];
|
|
103
|
+
getMessage?: GetMessage;
|
|
104
|
+
}
|
|
105
|
+
export interface CustomPropRule {
|
|
106
|
+
nameRule: ValidationRule;
|
|
107
|
+
valueRule: ValidationRule;
|
|
108
|
+
}
|
|
109
|
+
export interface ObjectRule {
|
|
110
|
+
type: 'object';
|
|
111
|
+
rules?: Record<string, ValidationRule>;
|
|
112
|
+
customPropRules?: CustomPropRule[];
|
|
113
|
+
getMessage?: GetMessage;
|
|
114
|
+
}
|
|
115
|
+
export interface ArrayRule {
|
|
116
|
+
type: 'array';
|
|
117
|
+
itemRule: ValidationRule;
|
|
118
|
+
getMessage?: GetMessage;
|
|
119
|
+
}
|
|
120
|
+
export type ValidationRule = RequiredRule | AnyRule | StringRule | NumberRule | BooleanRule | EmailRule | AlphanumericRule | RegexRule | MinLengthRule | MaxLengthRule | MinValueRule | MaxValueRule | EqualsRule | EqualsToFieldRule | CustomRule | RequiredArrayWithItemRule | OneOfRule | AllRule | ObjectRule | ArrayRule;
|
|
121
|
+
export type DefaultMessageCode = '##object' | '##array' | '##required' | '##equals' | '##maxLength' | '##minLength' | '##number' | '##minValue' | '##maxValue' | '##email' | '##alphanumeric' | '##string' | '##boolean' | '##equalsToField' | '##regex' | '##custom';
|
|
122
|
+
export type DefaultMessages = Partial<Record<DefaultMessageCode, string>>;
|
|
123
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,MAAM,CAAC;AAE1D;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,YAAY,GAAG,MAAM,GAAG,S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E,cAAc,EAAE,CAAC;IAC7B,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,cAAc,CAAC;IACzB,SAAS,EAAE,cAAc,CAAC;CAC3B;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACvC,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;IACnC,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,cAAc,CAAC;IACzB,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAMD,MAAM,MAAM,cAAc,GACtB,YAAY,GACZ,OAAO,GACP,UAAU,GACV,UAAU,GACV,WAAW,GACX,SAAS,GACT,gBAAgB,GAChB,SAAS,GACT,aAAa,GACb,aAAa,GACb,YAAY,GACZ,YAAY,GACZ,UAAU,GACV,iBAAiB,GACjB,UAAU,GACV,yBAAyB,GACzB,SAAS,GACT,OAAO,GACP,UAAU,GACV,SAAS,CAAC;AAMd,MAAM,MAAM,kBAAkB,GAC1B,UAAU,GACV,SAAS,GACT,YAAY,GACZ,UAAU,GACV,aAAa,GACb,aAAa,GACb,UAAU,GACV,YAAY,GACZ,YAAY,GACZ,SAAS,GACT,gBAAgB,GAChB,UAAU,GACV,WAAW,GACX,iBAAiB,GACjB,SAAS,GACT,UAAU,CAAC;AAEf,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC,CAAC"}
|
package/lib/types.js
ADDED
package/lib/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CustomRule, RequiredRule, AnyRule, RequiredArrayWithItemRule, EqualsRule, MaxLengthRule, MinLengthRule, NumberRule, MinValueRule, MaxValueRule, EmailRule, AlphanumericRule, StringRule, BooleanRule, EqualsToFieldRule, RegexRule, ValidatorFn } from './types';
|
|
2
|
+
export declare const custom: ({ validator, getMessage, }: CustomRule) => ValidatorFn;
|
|
3
|
+
export declare const required: ({ getMessage }: RequiredRule) => ValidatorFn;
|
|
4
|
+
export declare const any: (_rule: AnyRule) => ValidatorFn;
|
|
5
|
+
export declare const requiredArrayWithItem: ({ getMessage, }: RequiredArrayWithItemRule) => ValidatorFn;
|
|
6
|
+
export declare const equals: ({ to, getMessage }: EqualsRule) => ValidatorFn;
|
|
7
|
+
export declare const maxLength: ({ max, getMessage }: MaxLengthRule) => ValidatorFn;
|
|
8
|
+
export declare const minLength: ({ min, getMessage }: MinLengthRule) => ValidatorFn;
|
|
9
|
+
export declare const number: ({ getMessage }: NumberRule) => ValidatorFn;
|
|
10
|
+
export declare const minValue: ({ min, getMessage }: MinValueRule) => ValidatorFn;
|
|
11
|
+
export declare const maxValue: ({ max, getMessage }: MaxValueRule) => ValidatorFn;
|
|
12
|
+
export declare const email: ({ getMessage }: EmailRule) => ValidatorFn;
|
|
13
|
+
export declare const alphanumeric: ({ getMessage }: AlphanumericRule) => ValidatorFn;
|
|
14
|
+
export declare const string: ({ getMessage }: StringRule) => ValidatorFn;
|
|
15
|
+
export declare const boolean: ({ getMessage }: BooleanRule) => ValidatorFn;
|
|
16
|
+
export declare const equalsToField: ({ field, getMessage, }: EqualsToFieldRule) => ValidatorFn;
|
|
17
|
+
export declare const regex: ({ regex: regexPattern, getMessage }: RegexRule) => ValidatorFn;
|
|
18
|
+
//# sourceMappingURL=validators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../src/validators.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EACV,YAAY,EACZ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