co.validation 2.7.1 → 2.7.2
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.
|
@@ -427,7 +427,7 @@ describe('createValidation', () => {
|
|
|
427
427
|
expect((0, _.createValidation)({
|
|
428
428
|
type: 'number'
|
|
429
429
|
})('')).toEqual({
|
|
430
|
-
data:
|
|
430
|
+
data: null
|
|
431
431
|
});
|
|
432
432
|
expect((0, _.createValidation)({
|
|
433
433
|
type: 'number',
|
|
@@ -448,7 +448,7 @@ describe('createValidation', () => {
|
|
|
448
448
|
type: 'minValue',
|
|
449
449
|
min: 1
|
|
450
450
|
})('')).toEqual({
|
|
451
|
-
data:
|
|
451
|
+
data: null
|
|
452
452
|
});
|
|
453
453
|
expect((0, _.createValidation)({
|
|
454
454
|
type: 'minValue',
|
|
@@ -493,7 +493,7 @@ describe('createValidation', () => {
|
|
|
493
493
|
type: 'maxValue',
|
|
494
494
|
max: 10
|
|
495
495
|
})('')).toEqual({
|
|
496
|
-
data:
|
|
496
|
+
data: null
|
|
497
497
|
});
|
|
498
498
|
expect((0, _.createValidation)({
|
|
499
499
|
type: 'maxValue',
|
package/lib/validators.js
CHANGED
|
@@ -111,7 +111,7 @@ const normalizeNumber = value => {
|
|
|
111
111
|
const number = ({
|
|
112
112
|
getMessage
|
|
113
113
|
}) => value => value === '' ? {
|
|
114
|
-
data:
|
|
114
|
+
data: null
|
|
115
115
|
} : value !== null && value !== undefined && isNaN(normalizeNumber(value)) ? {
|
|
116
116
|
errors: (0, _messageProcessor.default)(getMessage, '##number')
|
|
117
117
|
} : {
|
|
@@ -124,7 +124,7 @@ const minValue = ({
|
|
|
124
124
|
min,
|
|
125
125
|
getMessage
|
|
126
126
|
}) => value => value === '' ? {
|
|
127
|
-
data:
|
|
127
|
+
data: null
|
|
128
128
|
} : !isNaN(value) && Number(value) < min ? {
|
|
129
129
|
errors: (0, _messageProcessor.default)(getMessage, `##minValue`, string => string.replace(/{min}/g, min), min)
|
|
130
130
|
} : {
|
|
@@ -137,7 +137,7 @@ const maxValue = ({
|
|
|
137
137
|
max,
|
|
138
138
|
getMessage
|
|
139
139
|
}) => value => value === '' ? {
|
|
140
|
-
data:
|
|
140
|
+
data: null
|
|
141
141
|
} : !isNaN(value) && Number(value) > max ? {
|
|
142
142
|
errors: (0, _messageProcessor.default)(getMessage, `##maxValue`, string => string.replace(/{max}/g, max), max)
|
|
143
143
|
} : {
|