UNPKG

node-input-validator

Version:

validation library for nodejs, inspired by laravel.

24 lines (19 loc) 527 B
const assert = require('assert'); const niv = require('../lib/index'); describe('Assert Rules', () => { it('should pass with valid rule', async () => { niv.assert({ password: 'required|string', }); }); it('should throw exception for non existing rule', async () => { try { niv.assert({ password: 'passIt', }); throw new Error('Invalid seed exception.'); } catch (e) { assert.equal(e, 'Error: Rule passIt used for attribute password is invalid.'); } }); });