Icontem

File: test/rules/acceptedNotIf.js

Recommend this page to a friend!
  Classes of Harcharan Singh  >  Node Input Validator  >  test/rules/acceptedNotIf.js  >  Download  
File: test/rules/acceptedNotIf.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Node Input Validator
Validate submitted input values in Node.js
Author: By
Last change: test case and ver upgrade
Date: 4 months ago
Size: 897 bytes
 

Contents

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

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

const messages = require('../../src/messages/en/messages');

let r = {};


describe('acceptedNotIf', function () {

    it('validation should pass: with yes', async () => {

        const v = new Validator(
            { attribute: 'no', age: 16 },
            { attribute: 'acceptedNotIf:age,16' }
        );

        const matched = await v.check();

        assert.equal(matched, true);

    });

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

        const v = new Validator(
            { attribute: 'yes', age: 16 },
            { attribute: 'acceptedNotIf:age,16' }
        );

        const matched = await v.check();

        assert.equal(matched, false);

        assert.equal(v.errors.attribute.message, v.parseExistingMessageOnly('acceptedNotIf', 'attribute', 'yes', ['age', '16']));

    });


});