# param-matcher

> a middleware for express to check parameters

Latest version **1.0.1** (published 2016-06-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install param-matcher
pnpm add param-matcher
yarn add param-matcher
bun add param-matcher
```

## 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.1 |
| Published | 2016-06-28 |
| First published | 2016-06-28 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | dirtypp |
| Maintainers | qinghua.pu |

## Links

- npm: https://www.npmjs.com/package/param-matcher
- npm.io page: https://npm.io/package/param-matcher

## Recent versions

- 1.0.1 (latest) — 2016-06-28

## README

# param-matcher
a middle-wear for Express to validate the parameters of request

usage:
```
  const Matcher = require("param-matcher");
  let router = Express.Route();
  
  let options = {
    id:"required;isInt",
    name:"optional;REGEXP:^[a-z_0-9]{6,20}$"
  } 
  router.all("/",Matcher.newMatcher(options),(req,res,next)=>{
      //TODO:your code
  }
  
```  
"required","optional" 2 items are mutual exclusion,and they must be the first item.

```Matcher.newMatcher(options,fail) ```

###### options：
an object contains key-values that used for specifying which method to match the parameter in request
  
  
###### fail:
a string variate,only 3 patterns, specifed which way to return the unmatch message.                  
1. ```""```  or ```"json"``` :return an msg object.                   
2. ```"redirect:${URL}"``` : redirect to the URL with unmatch message in the query string                               
3. ```"render:${templat}"``` : render the specified templat to browser,with unmatch message                    

`Matcher.setMatcher(name,matcher)`                        


###### name
a string to mark the matcher
###### matcher
a function to check the pattern ,if the pattern is matched return ```"ok"``` ,not return your tips

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