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

valuechecker

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

valuechecker

Easy extendable method collection for asserting values on runtime for NodeJS as well as Browser JS

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-60%
Maintainers
1
Weekly downloads
 
Created
Source

Simple example

// This line is for NodeJS. In browser, you just have to the JS-File
// using <script src="..." type="text/javascript"></script>
var VC = require('valuechecker');

/**
 * This method demonstrates the ValueChecker interface.
 *
 * @param {String} a_string  A string with length between 10 and 12.
 * @param {Integer} an_int   Just an int.
 * @param {CoolObj} cool_obj An object of type CoolObj.
 */
function noop(a_string, an_int, cool_obj) {
    a_string = VC.string(a_string, "a_string", null, 12, 10);
    an_int = VC.int(an_int, "an_int");
    cool_obj = VC.instance_of(cool_obj, "cool_obj", CoolObj);
};

The ValueChecker methods checks the given value for the type and additional criteria you want to check. If it does not match, an exception is thrown telling exactly what has happend (e.g. type mismatch or string is too short etc). If it does match, the value to check is returned casted to the type you wanted. Therefore if you pass for instance the string "2" to VC.int, then it will pass the test an the int value 2 will be returend. Because "2" is lossless convertable to an int.

Keywords

FAQs

Package last updated on 12 Nov 2013

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