Icontem

File: test/rules/same.js

Recommend this page to a friend!
  Classes of Harcharan Singh  >  Node Input Validator  >  test/rules/same.js  >  Download  
File: test/rules/same.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
Date: 4 months ago
Size: 870 bytes
 

Contents

Class file image Download
const assert = require('assert');

const Validator = require('../../index');


describe('#same', function () {

    it('should pass', async () => {

        let v, matched;

        v = new Validator(
            { password: '000000', confirm_password: '000000' },
            { password: 'required', confirm_password: 'required|same:password' });

        matched = await v.check();

        assert.equal(matched, true);
    })

    it('should fail', async () => {

        const v = new Validator(
            { password: '000000', confirm_password: '123456' },
            { password: 'required', confirm_password: 'required|same:password' });

        const matched = await v.check();

        assert.equal(matched, false);

        assert.equal(v.errors.confirm_password.message, v.parseExistingMessageOnly('same', 'confirm_password', '','password'));

    });

});