Icontem

File: test/rules/url.js

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

Contents

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

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


describe('#same', function () {

    it('#url', async () => {



        let v = new Validator({ url: 'http://www.github.com' }, { url: 'required|url' });

        let matched = await v.check();

        assert.equal(matched, true);


    });

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


        const v = new Validator({ url: 'artisangang' }, { url: 'required|url' });

        const matched = await v.check();

        assert.equal(matched, false);

        assert.equal(v.errors.url.message, v.parseExistingMessageOnly('url', 'url'));

    });

});