co.validation 1.0.0-RC.7 → 2.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.
|
@@ -370,21 +370,21 @@ describe('createValidation', () => {
|
|
|
370
370
|
type: 'boolean',
|
|
371
371
|
getMessage: () => 'Boolean'
|
|
372
372
|
})('true')).toEqual({
|
|
373
|
-
data:
|
|
373
|
+
data: true,
|
|
374
374
|
errors: undefined
|
|
375
375
|
});
|
|
376
376
|
expect((0, _.createValidation)({
|
|
377
377
|
type: 'boolean',
|
|
378
378
|
getMessage: () => 'Boolean'
|
|
379
379
|
})('false')).toEqual({
|
|
380
|
-
data:
|
|
380
|
+
data: false,
|
|
381
381
|
errors: undefined
|
|
382
382
|
});
|
|
383
383
|
expect((0, _.createValidation)({
|
|
384
384
|
type: 'boolean',
|
|
385
385
|
getMessage: () => 'Boolean'
|
|
386
386
|
})('FAlse')).toEqual({
|
|
387
|
-
data:
|
|
387
|
+
data: false,
|
|
388
388
|
errors: undefined
|
|
389
389
|
});
|
|
390
390
|
expect((0, _.createValidation)({
|
package/lib/validators.js
CHANGED
|
@@ -118,11 +118,18 @@ exports.string = string;
|
|
|
118
118
|
|
|
119
119
|
const boolean = ({
|
|
120
120
|
getMessage
|
|
121
|
-
}) => value => value === undefined || value === null
|
|
121
|
+
}) => value => value === undefined || value === null ? {
|
|
122
|
+
data: value
|
|
123
|
+
} : typeof value === 'boolean' ? {
|
|
124
|
+
data: value
|
|
125
|
+
} : typeof value === 'string' && {
|
|
122
126
|
'true': true,
|
|
123
127
|
'false': true
|
|
124
128
|
}[value.toLowerCase()] ? {
|
|
125
|
-
data:
|
|
129
|
+
data: {
|
|
130
|
+
'true': true,
|
|
131
|
+
'false': false
|
|
132
|
+
}[value.toLowerCase()]
|
|
126
133
|
} : {
|
|
127
134
|
errors: (0, _messageProcessor.default)(getMessage, 'Must be a boolean')
|
|
128
135
|
};
|