# valid-params

> Extract values from an object and return them with some transformations.

Latest version **0.0.1** (published 2013-12-22) · BSD-2-Clause license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2013-12-22 |
| First published | 2013-12-22 |
| Weekly downloads | 0 |
| License | BSD-2-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Antoine Proulx |
| Maintainers | magicienap |

## Links

- npm: https://www.npmjs.com/package/valid-params
- Repository: https://github.com/magicienap/valid-params
- Issues: https://github.com/magicienap/valid-params/issues
- npm.io page: https://npm.io/package/valid-params

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ~2.4.1

## Recent versions

- 0.0.1 (latest) — 2013-12-22

## README

# valid-params

This library is used to extract values from an objet and return them with some
transformations. It can be used to valid the parameters received from a web
application.

# Usage

```javascript
var validParams = require('valid-params');

var params = {
  firstName:   "Antoine",
  lastName:    "Proulx",
  phoneNumber: "123 456-7890",
  admin:       true
};

// The model defines what will be the object returned by validParams. The value
// of the key is a function that takes an argument representing the parameters
// to valid. This function should extract the required parameter(s) from it,
// transform it/them (if needed) and return the value. If it only needs to take
// the literal value from the params object, just assign the name of the the
// key.
var model  = {
  firstName:   'firstName',
  lastName:    'lastName',
  phoneNumber: function(params) {
    return params.phoneNumber.replace(/\D/g, "");
  }
};

validParams(params, model);
// Result
// { firstName: "Antoine", lastName: "Proulx", phoneNumber: "1234567890" }
```

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