Icontem

File: test/rules/dateBefore.js

Recommend this page to a friend!
  Classes of Harcharan Singh  >  Node Input Validator  >  test/rules/dateBefore.js  >  Download  
File: test/rules/dateBefore.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: test upgrades
test cases: later rewrite message verification
Date: 6 months ago
Size: 731 bytes
 

Contents

Class file image Download
const Validator = require('../../index');
const assert = require('assert');

describe('#before', function () {

    it('should return true', async () => {

        let v = new Validator({ dob: '1990-02-28' }, { dob: 'required|dateFormat:YYYY-MM-DD|dateBefore:1991-01-01' });

        let matched = await v.check();
        assert.equal(matched, true);

    });


    it('should return false', async () => {

        let v = new Validator({ dob: '1993-28-02' }, { dob: 'required|dateFormat:YYYY-MM-DD|dateBefore:1992-12-31' });

        let matched = await v.check();

        assert.equal(matched, false);

        assert.equal(v.errors.dob.message, v.parseExistingMessageOnly('dateFormat', 'dob', '', 'YYYY-MM-DD'));

    });

});