Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

normalize-json

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

normalize-json

Terse syntax for validating and normalizing JavaScript objects

  • 0.1.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Try normalize-json on RunKit

normalize-json

Terse syntax for validating and normalizing JavaScript objects in Node.

const nJ = require('normalize-json');

// a schema looks like this!
let validator = nJ({
    name: [String, 30], // a string with <= 30 characters
    age: [Number, 0, 100], // a number between 0 and 100, inclusive
    color: ['red', 'yellow', 'blue'] // must be one of these three values
});

// here's how we might validate/normalize an object
let obj = {
    name: ' Nigel   ', // this string will be trimmed!
    age: 23,
    color: 'blue',
    someUndefinedField: undefined // undefined fields will be stripped out
};

let result = validator(obj); // 'result' is a new object; 'obj' has not been changed
console.log(result); // { name: 'Nigel', age: 23, color: 'blue' }

Try it out!

You can try out normalize-json in your browser at npm.runkit.com/normalize-json.

API

TODO

Keywords

FAQs

Package last updated on 14 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