UNPKG

node-input-validator

Version:

validation library for nodejs, inspired by laravel.

63 lines (48 loc) 1.35 kB
const assert = require('assert'); const Validator = require('../../index'); describe('lte', () => { it('validation should pass with greater seed', async () => { const v = new Validator( { min: '20', max: '25' }, { min: 'required|integer|lte:max', max: 'required|integer', } ); const matched = await v.check(); assert.equal(matched, true); }); it('validation should pass with equal', async () => { const v = new Validator( { min: '20', max: '20' }, { min: 'required|integer|lte:max', max: 'required|integer', } ); const matched = await v.check(); assert.equal(matched, true); }); it('validation should fail', async () => { const v = new Validator( { min: '30', max: '25' }, { min: 'required|integer|lte:max', max: 'required|integer', } ); const matched = await v.check(); assert.equal(matched, false); }); it('validation should fail due to nan in another field', async () => { const v = new Validator( { min: '30', max: 'abc' }, { min: 'required|integer|lte:max', max: 'required', } ); const matched = await v.check(); assert.equal(matched, false); }); });