co.validation 2.4.1 → 2.5.1
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.
|
@@ -3,6 +3,20 @@
|
|
|
3
3
|
var _ = require("..");
|
|
4
4
|
|
|
5
5
|
describe('createValidation', () => {
|
|
6
|
+
it('supports any', () => {
|
|
7
|
+
expect((0, _.createValidation)({
|
|
8
|
+
type: 'any'
|
|
9
|
+
})('')).toEqual({
|
|
10
|
+
data: '',
|
|
11
|
+
errors: undefined
|
|
12
|
+
});
|
|
13
|
+
expect((0, _.createValidation)({
|
|
14
|
+
type: 'any'
|
|
15
|
+
})(5)).toEqual({
|
|
16
|
+
data: 5,
|
|
17
|
+
errors: undefined
|
|
18
|
+
});
|
|
19
|
+
});
|
|
6
20
|
it('supports required', () => {
|
|
7
21
|
expect((0, _.createValidation)({
|
|
8
22
|
type: 'required'
|
package/lib/createValidation.js
CHANGED
|
@@ -17,6 +17,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
17
17
|
|
|
18
18
|
const createValidation = rule => {
|
|
19
19
|
switch (rule.type) {
|
|
20
|
+
case 'any':
|
|
21
|
+
return (0, _validators.any)(rule);
|
|
22
|
+
|
|
20
23
|
case 'required':
|
|
21
24
|
return (0, _validators.required)(rule);
|
|
22
25
|
|
package/lib/validators.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
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.required = exports.custom = void 0;
|
|
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
7
|
|
|
8
8
|
var _messageProcessor = _interopRequireDefault(require("./messageProcessor"));
|
|
9
9
|
|
|
@@ -36,6 +36,12 @@ const required = ({
|
|
|
36
36
|
|
|
37
37
|
exports.required = required;
|
|
38
38
|
|
|
39
|
+
const any = ({}) => value => ({
|
|
40
|
+
data: value
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
exports.any = any;
|
|
44
|
+
|
|
39
45
|
const requiredArrayWithItem = ({
|
|
40
46
|
getMessage
|
|
41
47
|
}) => value => {
|