File: test/postRules/any.js

Recommend this page to a friend!
  Classes of Harcharan Singh   Node Input Validator   test/postRules/any.js   Download  
File: test/postRules/any.js
Role: Example script
Content type: text/plain
Description: Example script
Class: Node Input Validator
Validate submitted input values in Node.js
Author: By
Last change: Update of test/postRules/any.js
Date: 2 years ago
Size: 646 bytes
 

Contents

Class file image Download
/* eslint-disable no-undef */ const assert = require('assert'); const { Validator } = require('../../lib/index'); describe('Post', () => { describe('any', () => { it('should return true when at least one field exists', async () => { const v = new Validator({ field1: '1' }, { '*': 'any:field1,field2,field3' }); const matched = await v.check(); assert.equal(matched, true); }); it('should return false when there is no fields', async () => { const v = new Validator({}, { '*': 'any:field1,field2,field3' }); const matched = await v.check(); assert.equal(matched, false); }); }); });