New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

caretaker

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

caretaker

lean parameters and define defaults.

latest
Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
2
-50%
Maintainers
1
Weekly downloads
 
Created
Source

caretaker

Clean parameters and define defaults.

Build Status

Installation

npm install caretaker
var caretaker = require('caretaker')
var cleaned = caretaker.clean(valid, params)

Options

Valid is an object containing keys with an options object. Each parameter is parsed by either opt.type field or typeof opt.default (supports string, number, boolean, or 'default'). If a parameter is undefined, opt.default will be used, otherwise not included in the cleaned object. Also available are opt.required and opt.match for strings.

The caretaker.clean() function returns an cleaned object with a status. If cleaned.status === 'ok', cleaned.params contains the resulting parameters. Otherwise cleaned.errors will contain errors genereated by either opts.required, opts.match or a non-parsing value.

var valid = {
  num: { default: 10 },
  str: { type: 'string', match: /^([a-z]{1,})$/ },
  boo: { type: 'boolean', required: true }
}

var cleaned = caretaker.clean(valid, { str: 'a', boo: 1 })
// cleaned = { status: 'ok', params: { num: 10, str: 'a', boo: true } }

cleaned = caretaker.clean(valid, { str: '9' })
// cleaned = { status: 'error', errors: { str: 'is not allowed', boo: 'is required' } }

FAQs

Package last updated on 21 May 2012

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