-
Notifications
You must be signed in to change notification settings - Fork 2
/
array.js
33 lines (31 loc) · 1.21 KB
/
array.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* eslint-disable no-unused-vars, no-console */
const makeValidation = require('../lib');
const result = makeValidation((types) => {
return {
payload: {
key1: [], // invalid
key2: [], // valid
key3: ['john', 'doe'], // valid
key4: ['john', 'doe', 'john'], // invalid
key5: ['john', 'doe', 'john'], // valid
key6: 'invalid type', // invalid
key7: ['array', 'of', 'strings', 'only'], // valid
key8: ['array', 'of', 'strings', 'only', 77777, 'invalid'], // invalid
key9: ['array', 'of', 'strings', 'only', 77777, 'invalid'], // valid
},
checks: {
key1: { type: types.array },
key2: { type: types.array, options: { empty: true } },
key3: { type: types.array },
key4: { type: types.array, options: { unique: true } },
key5: { type: types.array, options: { unique: false } },
key6: { type: types.array },
key7: { type: types.array, options: { stringOnly: false } },
key8: { type: types.array, options: { stringOnly: true } },
key9: { type: types.array, options: { stringOnly: false } },
},
};
});
console.log('success', result.success);
console.log('message', result.message);
console.log('errors', result.errors);