New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

can-validate-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

can-validate-interface

Utility to validate property existence. Test for missing properties before they cause errors later.

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.9K
decreased by-31.15%
Maintainers
1
Weekly downloads
 
Created
Source

can-validate-interface

Utility to validate property existence. Test for missing properties before they cause errors later.

  • makeInterfaceValidator(propertyArrays)

API

can-validate-interface function

Validate objects for property existence

makeInterfaceValidator(propertyArrays)

Get a function that validates a given object for the provided properties:

var makeInterfaceValidator = require("can-validate-interface");
var dataMethods = ["create","read","update","delete"];
var daoValidator = makeInterfaceValidator([dataMethods, "id"]);

var dao = {
    create: function() {},
    read: function() {},
    update: function() {},
    delete: function() {}
};

var errors = daoValidator(dao);
// errors == {message:"missing expected properties", related: ["id"]}

dao.id = 10;

errors = daoValidator(dao);
// errors == undefined
  1. propertyArrays {Array<String, Array<String>}: Property names and arrays of property names to validate existence of.
  • returns {function(object): {{message:String, related:Array<String>}}: Function that validates an object for properties in propertyArrays and returns an error record or undefined if no properties are missing.

Contributing

Making a Build

To make a build of the distributables into dist/ in the cloned repository run

npm install
node build

Running the tests

Tests can run in the browser by opening a webserver and visiting the test.html page. Automated tests that run the tests from the command line in Firefox can be run with

npm test

Keywords

FAQs

Package last updated on 22 May 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc