co.validation 2.7.1 → 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.
Files changed (41) hide show
  1. package/lib/createValidation.d.ts +6 -0
  2. package/lib/createValidation.d.ts.map +1 -0
  3. package/lib/createValidation.js +153 -204
  4. package/lib/createValidation.js.map +1 -0
  5. package/lib/helpers.d.ts +2 -0
  6. package/lib/helpers.d.ts.map +1 -0
  7. package/lib/helpers.js +4 -8
  8. package/lib/helpers.js.map +1 -0
  9. package/lib/index.d.ts +7 -0
  10. package/lib/index.d.ts.map +1 -0
  11. package/lib/index.js +18 -38
  12. package/lib/index.js.map +1 -0
  13. package/lib/messageProcessor.d.ts +7 -0
  14. package/lib/messageProcessor.d.ts.map +1 -0
  15. package/lib/messageProcessor.js +45 -51
  16. package/lib/messageProcessor.js.map +1 -0
  17. package/lib/operators.d.ts +4 -0
  18. package/lib/operators.d.ts.map +1 -0
  19. package/lib/operators.js +60 -71
  20. package/lib/operators.js.map +1 -0
  21. package/lib/types.d.ts +123 -0
  22. package/lib/types.d.ts.map +1 -0
  23. package/lib/types.js +3 -0
  24. package/lib/types.js.map +1 -0
  25. package/lib/validators.d.ts +18 -0
  26. package/lib/validators.d.ts.map +1 -0
  27. package/lib/validators.js +164 -196
  28. package/lib/validators.js.map +1 -0
  29. package/package.json +13 -21
  30. package/tsconfig.json +32 -0
  31. package/lib/__tests__/component.arrayValidation.js +0 -201
  32. package/lib/__tests__/component.objectValidation.js +0 -556
  33. package/lib/__tests__/component.reduxFormValidation.js +0 -20
  34. package/lib/__tests__/component.valueValidation.js +0 -923
  35. package/lib/__tests__/integration.objectValidation.js +0 -64
  36. package/lib/__tests__/integration.registrationForm.js +0 -234
  37. package/lib/__tests__/integration.valueValidation.js +0 -448
  38. package/lib/__tests__/operators.js +0 -28
  39. package/lib/__tests__/unit.operators.js +0 -125
  40. package/lib/createObjectValidation.js +0 -34
  41. package/lib/createValueValidation.js +0 -71
package/lib/validators.js CHANGED
@@ -1,220 +1,188 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.regex = exports.equalsToField = exports.boolean = exports.string = exports.alphanumeric = exports.email = exports.maxValue = exports.minValue = exports.number = exports.minLength = exports.maxLength = exports.equals = exports.requiredArrayWithItem = exports.any = exports.required = exports.custom = void 0;
7
-
8
- var _messageProcessor = _interopRequireDefault(require("./messageProcessor"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- const custom = ({
13
- validator,
14
- getMessage
15
- }) => (value, allValues) => {
16
- try {
17
- return {
18
- data: validator(value, allValues)
19
- };
20
- } catch (e) {
21
- return {
22
- errors: (0, _messageProcessor.default)(getMessage, '##custom', null, e)
7
+ const messageProcessor_1 = __importDefault(require("./messageProcessor"));
8
+ const custom = ({ validator, getMessage, }) => {
9
+ return (value, allValues) => {
10
+ try {
11
+ return { data: validator(value, allValues) };
12
+ }
13
+ catch (e) {
14
+ return { errors: (0, messageProcessor_1.default)(getMessage, '##custom', null, e) };
15
+ }
23
16
  };
24
- }
25
17
  };
26
-
27
18
  exports.custom = custom;
28
-
29
- const required = ({
30
- getMessage
31
- }) => value => value || typeof value === 'number' || typeof value === 'boolean' ? {
32
- data: value
33
- } : {
34
- errors: (0, _messageProcessor.default)(getMessage, '##required')
35
- };
36
-
19
+ const required = ({ getMessage }) => {
20
+ return (value) => {
21
+ return value || typeof value === 'number' || typeof value === 'boolean'
22
+ ? { data: value }
23
+ : { errors: (0, messageProcessor_1.default)(getMessage, '##required') };
24
+ };
25
+ };
37
26
  exports.required = required;
38
-
39
- const any = ({}) => value => ({
40
- data: value
41
- });
42
-
27
+ const any = (_rule) => {
28
+ return (value) => ({ data: value });
29
+ };
43
30
  exports.any = any;
44
-
45
- const requiredArrayWithItem = ({
46
- getMessage
47
- }) => value => {
48
- if (Array.isArray(value)) {
49
- return value.length > 0 ? {
50
- data: value
51
- } : {
52
- errors: (0, _messageProcessor.default)(getMessage, '##required')
31
+ const requiredArrayWithItem = ({ getMessage, }) => {
32
+ return (value) => {
33
+ if (Array.isArray(value)) {
34
+ return value.length > 0
35
+ ? { data: value }
36
+ : { errors: (0, messageProcessor_1.default)(getMessage, '##required') };
37
+ }
38
+ return {
39
+ errors: (0, messageProcessor_1.default)(getMessage, '##array'),
40
+ };
53
41
  };
54
- }
55
-
56
- return {
57
- errors: (0, _messageProcessor.default)(getMessage, `##array`)
58
- };
59
42
  };
60
-
61
43
  exports.requiredArrayWithItem = requiredArrayWithItem;
62
-
63
- const equals = ({
64
- to,
65
- getMessage
66
- }) => value => value === to ? {
67
- data: value
68
- } : {
69
- errors: (0, _messageProcessor.default)(getMessage, `##equals`, string => string.replace(/{to}/g, to), to)
70
- };
71
-
44
+ const equals = ({ to, getMessage }) => {
45
+ return (value) => {
46
+ return value === to
47
+ ? { data: value }
48
+ : {
49
+ errors: (0, messageProcessor_1.default)(getMessage, '##equals', (string) => string.replace(/{to}/g, String(to)), to),
50
+ };
51
+ };
52
+ };
72
53
  exports.equals = equals;
73
-
74
54
  function getStringLength(str) {
75
- const splitGraphemes = str.split(/[\ufe00-\ufe0f]/).join('').match(/./gu);
76
- return splitGraphemes ? splitGraphemes.length : 0;
55
+ const splitGraphemes = str.split(/[\ufe00-\ufe0f]/).join('').match(/./gu);
56
+ return splitGraphemes ? splitGraphemes.length : 0;
77
57
  }
78
-
79
- const maxLength = ({
80
- max,
81
- getMessage
82
- }) => value => {
83
- return value && getStringLength(value) > max ? {
84
- errors: (0, _messageProcessor.default)(getMessage, `##maxLength`, string => string.replace(/{max}/g, max), max)
85
- } : {
86
- data: value
87
- };
88
- };
89
-
58
+ const maxLength = ({ max, getMessage }) => {
59
+ return (value) => {
60
+ return value && getStringLength(value) > max
61
+ ? {
62
+ errors: (0, messageProcessor_1.default)(getMessage, '##maxLength', (string) => string.replace(/{max}/g, String(max)), max),
63
+ }
64
+ : { data: value };
65
+ };
66
+ };
90
67
  exports.maxLength = maxLength;
91
-
92
- const minLength = ({
93
- min,
94
- getMessage
95
- }) => value => value && getStringLength(value) < min ? {
96
- errors: (0, _messageProcessor.default)(getMessage, `##minLength`, string => string.replace(/{min}/g, min), min)
97
- } : {
98
- data: value
99
- };
100
-
68
+ const minLength = ({ min, getMessage }) => {
69
+ return (value) => {
70
+ return value && getStringLength(value) < min
71
+ ? {
72
+ errors: (0, messageProcessor_1.default)(getMessage, '##minLength', (string) => string.replace(/{min}/g, String(min)), min),
73
+ }
74
+ : { data: value };
75
+ };
76
+ };
101
77
  exports.minLength = minLength;
102
-
103
- const normalizeNumber = value => {
104
- if (typeof value === 'number') {
105
- return value;
106
- }
107
-
108
- return Number(value?.replace(',', '.'));
109
- };
110
-
111
- const number = ({
112
- getMessage
113
- }) => value => value === '' ? {
114
- data: undefined
115
- } : value !== null && value !== undefined && isNaN(normalizeNumber(value)) ? {
116
- errors: (0, _messageProcessor.default)(getMessage, '##number')
117
- } : {
118
- data: value === null || value === undefined ? value : normalizeNumber(value)
119
- };
120
-
78
+ const normalizeNumber = (value) => {
79
+ if (typeof value === 'number') {
80
+ return value;
81
+ }
82
+ return Number(value === null || value === void 0 ? void 0 : value.replace(',', '.'));
83
+ };
84
+ const number = ({ getMessage }) => {
85
+ return (value) => {
86
+ if (value === '') {
87
+ return { data: null };
88
+ }
89
+ if (value !== null && value !== undefined && isNaN(normalizeNumber(value))) {
90
+ return { errors: (0, messageProcessor_1.default)(getMessage, '##number') };
91
+ }
92
+ return {
93
+ data: value === null || value === undefined ? value : normalizeNumber(value),
94
+ };
95
+ };
96
+ };
121
97
  exports.number = number;
122
-
123
- const minValue = ({
124
- min,
125
- getMessage
126
- }) => value => value === '' ? {
127
- data: undefined
128
- } : !isNaN(value) && Number(value) < min ? {
129
- errors: (0, _messageProcessor.default)(getMessage, `##minValue`, string => string.replace(/{min}/g, min), min)
130
- } : {
131
- data: Number(value)
132
- };
133
-
98
+ const minValue = ({ min, getMessage }) => {
99
+ return (value) => {
100
+ if (value === '') {
101
+ return { data: null };
102
+ }
103
+ if (!isNaN(value) && Number(value) < min) {
104
+ return {
105
+ errors: (0, messageProcessor_1.default)(getMessage, '##minValue', (string) => string.replace(/{min}/g, String(min)), min),
106
+ };
107
+ }
108
+ return { data: Number(value) };
109
+ };
110
+ };
134
111
  exports.minValue = minValue;
135
-
136
- const maxValue = ({
137
- max,
138
- getMessage
139
- }) => value => value === '' ? {
140
- data: undefined
141
- } : !isNaN(value) && Number(value) > max ? {
142
- errors: (0, _messageProcessor.default)(getMessage, `##maxValue`, string => string.replace(/{max}/g, max), max)
143
- } : {
144
- data: Number(value)
145
- };
146
-
112
+ const maxValue = ({ max, getMessage }) => {
113
+ return (value) => {
114
+ if (value === '') {
115
+ return { data: null };
116
+ }
117
+ if (!isNaN(value) && Number(value) > max) {
118
+ return {
119
+ errors: (0, messageProcessor_1.default)(getMessage, '##maxValue', (string) => string.replace(/{max}/g, String(max)), max),
120
+ };
121
+ }
122
+ return { data: Number(value) };
123
+ };
124
+ };
147
125
  exports.maxValue = maxValue;
148
126
  const emailRegex = /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i;
149
-
150
- const email = ({
151
- getMessage
152
- }) => value => value && !emailRegex.test(value) ? {
153
- errors: (0, _messageProcessor.default)(getMessage, '##email')
154
- } : {
155
- data: value
156
- };
157
-
127
+ const email = ({ getMessage }) => {
128
+ return (value) => {
129
+ return value && !emailRegex.test(value)
130
+ ? { errors: (0, messageProcessor_1.default)(getMessage, '##email') }
131
+ : { data: value };
132
+ };
133
+ };
158
134
  exports.email = email;
159
-
160
- const alphanumeric = ({
161
- getMessage
162
- }) => value => value && /[^a-zA-Z0-9]/i.test(value) ? {
163
- errors: (0, _messageProcessor.default)(getMessage, '##alphanumeric')
164
- } : {
165
- data: value
166
- };
167
-
135
+ const alphanumeric = ({ getMessage }) => {
136
+ return (value) => {
137
+ return value && /[^a-zA-Z0-9]/i.test(value)
138
+ ? { errors: (0, messageProcessor_1.default)(getMessage, '##alphanumeric') }
139
+ : { data: value };
140
+ };
141
+ };
168
142
  exports.alphanumeric = alphanumeric;
169
-
170
- const string = ({
171
- getMessage
172
- }) => value => value && typeof value !== 'string' ? {
173
- errors: (0, _messageProcessor.default)(getMessage, '##string')
174
- } : {
175
- data: value
176
- };
177
-
143
+ const string = ({ getMessage }) => {
144
+ return (value) => {
145
+ return value && typeof value !== 'string'
146
+ ? { errors: (0, messageProcessor_1.default)(getMessage, '##string') }
147
+ : { data: value };
148
+ };
149
+ };
178
150
  exports.string = string;
179
-
180
- const boolean = ({
181
- getMessage
182
- }) => value => value === undefined || value === null ? {
183
- data: value
184
- } : typeof value === 'boolean' ? {
185
- data: value
186
- } : typeof value === 'string' && {
187
- 'true': true,
188
- 'false': true
189
- }[value.toLowerCase()] ? {
190
- data: {
191
- 'true': true,
192
- 'false': false
193
- }[value.toLowerCase()]
194
- } : {
195
- errors: (0, _messageProcessor.default)(getMessage, '##boolean')
196
- };
197
-
151
+ const boolean = ({ getMessage }) => {
152
+ return (value) => {
153
+ if (value === undefined || value === null) {
154
+ return { data: value };
155
+ }
156
+ if (typeof value === 'boolean') {
157
+ return { data: value };
158
+ }
159
+ if (typeof value === 'string' &&
160
+ { true: true, false: true }[value.toLowerCase()]) {
161
+ return {
162
+ data: { true: true, false: false }[value.toLowerCase()],
163
+ };
164
+ }
165
+ return { errors: (0, messageProcessor_1.default)(getMessage, '##boolean') };
166
+ };
167
+ };
198
168
  exports.boolean = boolean;
199
-
200
- const equalsToField = ({
201
- field,
202
- getMessage
203
- }) => (value, allValues) => value !== allValues[field] ? {
204
- errors: (0, _messageProcessor.default)(getMessage, `##equalsToField`, string => string.replace(/{field}/g, field), field)
205
- } : {
206
- data: value
207
- };
208
-
169
+ const equalsToField = ({ field, getMessage, }) => {
170
+ return (value, allValues) => {
171
+ const allValuesObj = allValues;
172
+ return value !== allValuesObj[field]
173
+ ? {
174
+ errors: (0, messageProcessor_1.default)(getMessage, '##equalsToField', (string) => string.replace(/{field}/g, field), field),
175
+ }
176
+ : { data: value };
177
+ };
178
+ };
209
179
  exports.equalsToField = equalsToField;
210
-
211
- const regex = ({
212
- regex,
213
- getMessage
214
- }) => value => value && !regex.test(value) ? {
215
- errors: (0, _messageProcessor.default)(getMessage, '##regex')
216
- } : {
217
- data: value
218
- };
219
-
220
- exports.regex = regex;
180
+ const regex = ({ regex: regexPattern, getMessage }) => {
181
+ return (value) => {
182
+ return value && !regexPattern.test(value)
183
+ ? { errors: (0, messageProcessor_1.default)(getMessage, '##regex') }
184
+ : { data: value };
185
+ };
186
+ };
187
+ exports.regex = regex;
188
+ //# sourceMappingURL=validators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.js","sourceRoot":"","sources":["../src/validators.ts"],"names":[],"mappings":";;;;;;AAAA,0EAAkD;AAsB3C,MAAM,MAAM,GAAG,CAAC,EACrB,SAAS,EACT,UAAU,GACC,EAAe,EAAE;IAC5B,OAAO,CAAC,KAAc,EAAE,SAAmB,EAAoB,EAAE;QAC/D,IAAI,CAAC;YACH,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,CAAC;QAC/C,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,EAAE,MAAM,EAAE,IAAA,0BAAgB,EAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;QACvE,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAXW,QAAA,MAAM,UAWjB;AAEK,MAAM,QAAQ,GAAG,CAAC,EAAE,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e,EAAE;IACnF,OAAO,CAAC,KAAc,EAAoB,EAAE;QAC1C,OAAO,KAAK,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAe,CAAC;YACjD,CAAC,CAAC,EAAE,MAAM,EAAE,IAAA,0BAAgB,EAAC,UAAU,EAAE,SAAS,CAAC,EAAE;YACrD,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC,CAAC;AANW,QAAA,KAAK,SAMhB"}
package/package.json CHANGED
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "name": "co.validation",
3
- "version": "2.7.1",
3
+ "version": "3.0.0",
4
4
  "description": "JSON based fluent validation for browser, node.js, redux-form and anything javascript compatible.",
5
5
  "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
6
7
  "scripts": {
7
8
  "test": "jest",
8
- "build": "babel src --out-dir lib",
9
- "prepare": "npm run build"
9
+ "build": "tsc",
10
+ "prepare": "npm run build",
11
+ "tsc": "tsc --noEmit"
10
12
  },
11
13
  "keywords": [
12
14
  "validation"
@@ -14,27 +16,17 @@
14
16
  "author": "Collaboracia OÜ",
15
17
  "license": "ISC",
16
18
  "devDependencies": {
17
- "@babel/cli": "^7.4.4",
18
- "@babel/core": "^7.4.4",
19
- "@babel/preset-env": "^7.4.4",
20
- "babel-jest": "^24.7.1",
21
- "jest": "^24.7.1"
22
- },
23
- "babel": {
24
- "presets": [
25
- [
26
- "@babel/preset-env",
27
- {
28
- "targets": {
29
- "node": "current"
30
- }
31
- }
32
- ]
33
- ]
19
+ "@types/jest": "^29.5.12",
20
+ "@types/node": "^20.14.0",
21
+ "jest": "^29.7.0",
22
+ "ts-jest": "^29.1.4",
23
+ "typescript": "^5.4.5"
34
24
  },
35
25
  "jest": {
26
+ "preset": "ts-jest",
27
+ "testEnvironment": "node",
36
28
  "testMatch": [
37
- "**/src/__tests__/**/*.[jt]s?(x)"
29
+ "**/src/__tests__/**/*.ts"
38
30
  ]
39
31
  }
40
32
  }
package/tsconfig.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2018",
4
+ "module": "CommonJS",
5
+ "lib": ["ES2018"],
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "sourceMap": true,
9
+ "outDir": "./lib",
10
+ "rootDir": "./src",
11
+ "strict": true,
12
+ "noImplicitAny": true,
13
+ "strictNullChecks": true,
14
+ "strictFunctionTypes": true,
15
+ "strictBindCallApply": true,
16
+ "strictPropertyInitialization": true,
17
+ "noImplicitThis": true,
18
+ "useUnknownInCatchVariables": true,
19
+ "alwaysStrict": true,
20
+ "noUnusedLocals": true,
21
+ "noUnusedParameters": true,
22
+ "noImplicitReturns": true,
23
+ "noFallthroughCasesInSwitch": true,
24
+ "noUncheckedIndexedAccess": false,
25
+ "esModuleInterop": true,
26
+ "skipLibCheck": true,
27
+ "forceConsistentCasingInFileNames": true,
28
+ "resolveJsonModule": true
29
+ },
30
+ "include": ["src/**/*.ts"],
31
+ "exclude": ["node_modules", "lib", "src/__tests__"]
32
+ }