# req-validator

> http requests' filters, vaidators

Latest version **0.0.7** (published 2015-05-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install req-validator
pnpm add req-validator
yarn add req-validator
bun add req-validator
```

## 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.7 |
| Published | 2015-05-18 |
| First published | 2015-01-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+3 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | calidion |
| Maintainers | calidion |
| Keywords | sails, req, http, param, validator |

## Links

- npm: https://www.npmjs.com/package/req-validator
- Repository: https://github.com/calidion/req-validator
- Issues: https://github.com/calidion/req-validator/issues
- npm.io page: https://npm.io/package/req-validator

## Dependencies (1)

- [validator](https://npm.io/package/validator.md) ^3.27.0

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 0.0.7 (latest) — 2015-05-18
- 0.0.6 — 2015-03-27
- 0.0.5 — 2015-02-05
- 0.0.4 — 2015-02-04
- 0.0.3 — 2015-02-04
- 0.0.2 — 2015-02-03
- 0.0.1 — 2015-01-11

## README

sails-params
============

params extraction for sails

```javascript

//Inside sails controller
module.exports = {
  add: function (req, res) {

    var filter = require("sails-params");

    var params = [
      {name: 'key', alias: 'alias'},
      'key1'
    ];
    var data = {};

    if (!filter.extract(req, data, params)) {
      return false;
    }
    
    //You will have
    //data.alias
    //data.key1
    //assigned

  }
}

```

params validation


```javascript

var params = {
        k1: '13581723443',
        k2: 'hello',
        k3: 'http://www.foobar.com/'
      };
      var confs = {
        k1: {

            type: 'phone',
            locale: 'zh-CN'

        },
        k2: {
          type: 'string',
          minLength: 3,
          maxLength: 5
        },
        k3: {
          type: 'url'
        }
      };
      var error = {};

      assert.equal(true, filter.validate(params, confs, error));
      assert.equal(false, error.key == 'k1');
      assert.equal(false, 'Not validate key k1' == error.reason);
      
    ```

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