UNPKG

646 BJavaScriptView Raw
1/* eslint-disable no-undef */
2const assert = require('assert');
3
4const { Validator } = require('../../lib/index');
5
6describe('Post', () => {
7 describe('any', () => {
8 it('should return true when at least one field exists', async () => {
9 const v = new Validator({ field1: '1' }, { '*': 'any:field1,field2,field3' });
10
11 const matched = await v.check();
12
13 assert.equal(matched, true);
14 });
15
16 it('should return false when there is no fields', async () => {
17 const v = new Validator({}, { '*': 'any:field1,field2,field3' });
18
19 const matched = await v.check();
20
21 assert.equal(matched, false);
22 });
23 });
24});