🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

chai-interface

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chai-interface

chai assertions about an object's interface

2.0.3
latest
Source
npm
Version published
Weekly downloads
3.5K
35.04%
Maintainers
1
Weekly downloads
 
Created
Source

chai-interface

chai assertions about an object's interface

installation

$ npm install chai-interface

usage

    var chai = require('chai')
    chai.should()
    chai.use(require('chai-interface'))

    var foo = {
      bar: true,
      baz: 'green',
      qux: 37,
      quack: function () {},
      ducks: [1, 2, 3]
    }

    foo.should.have.interface({
      bar: Boolean,
      baz: String,
      qux: Number,
      quack: Function,
      ducks: Array
    })

Also, more complex, nested objects!

    var user = {
      name: {
        first: 'Betty',
        last: 'Dodson'
      },
      emails: {
        work: 'b.dodson@megacorp.com',
        home: 'butterflychica947@lol.com',
        school: 'bdodso4@stateu.edu'
      }
    }

    user.should.have.interface({
      name: {
        first: String,
        last: String
      },
      emails: {
        work: String,
        home: String,
        school: String
      }
    })

example error message

Interface not as expected:
{
  "bars": {
    "actual": "Array<String>",
    "expected": "Array<Number>",
    "actualValue": [
      "a",
      "b",
      "c"
    ]
  }
}

by the power of tracery

chai-interface does interface checking using tracery

contributors

jden jason@denizac.org @leJDen

Please submit pull requests and issues through github.

license

MIT (c) 2013 Agile Diagnosis, Inc. see LICENSE.md

Keywords

chai

FAQs

Package last updated on 18 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts