# validate-params

> A small parameter validation library

Latest version **1.0.0** (published 2015-10-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install validate-params
pnpm add validate-params
yarn add validate-params
bun add validate-params
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2015-10-27 |
| First published | 2015-10-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Mike Dvorscak |
| Maintainers | mdvorscak |
| Keywords | parameter, validation, type, check, validate, param, params |

## Links

- npm: https://www.npmjs.com/package/validate-params
- Repository: https://github.com/mdvorscak/validate-params
- Homepage: https://github.com/mdvorscak/validate-params#readme
- Issues: https://github.com/mdvorscak/validate-params/issues
- npm.io page: https://npm.io/package/validate-params

## Alternatives

- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2015-10-27

## README

# validate-params
**A small parameter validation library**

The purpose of this library is to easily check that the contract of your functions are not violated; and if they are,
to allow you to gracefully handle the situation (provide useful error messages).

[![Build Status][travis-image]][travis-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Code Climate][cc-image]][cc-url]

# Basic examples
```js
var Validator = require('validate-params');

// validating a single argument
function simpleWrapper(callback){
    Validator.assert.arg(callback, 'function');
    //Then do something with the callback later
    //At this point we can be sure that callback is a function
}

simpleWrapper(42); //throws Error('Expected type "function" but it was type "number"')

// validating an argument object
function myCoolFunction(opts){
    Validator.assert.arg(opts,
    {name: 'string',
    //handles optional parameters
     phoneNum: {
        type: 'string',
        optional: true
     },
     //handles nested objects
     location: {
        city: 'string',
        longitude: 'number',
        latitude: 'number'
     }
    });
    //...
}

myCoolFunction({name: 'Jenny',
                phoneNum: '876-5309',
                location: {
                   city: 'Chicago',
                   longitude: 87.6847,
                   latitude: 41.8369
                }
               });

```

# Documentation
To learn more checkout the [documentation page] (docs/index.md)

# License
MIT - [view the full license here] (LICENSE)

[travis-url]: https://travis-ci.org/mdvorscak/validate-params
[travis-image]: https://travis-ci.org/mdvorscak/validate-params.svg?branch=master

[coveralls-url]: https://coveralls.io/r/mdvorscak/validate-params?branch=master
[coveralls-image]: https://coveralls.io/repos/mdvorscak/validate-params/badge.svg?branch=master

[cc-url]: https://codeclimate.com/github/mdvorscak/validate-params
[cc-image]: https://codeclimate.com/github/mdvorscak/validate-params/badges/gpa.svg

---
_Source: https://npm.io/package/validate-params · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
