Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-validator

Package Overview
Dependencies
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-validator - npm Package Compare versions

Comparing version 0.2.3 to 0.2.4

test/regex.js

13

lib/express_validator.js

@@ -34,3 +34,4 @@ /*

// route params like /user/:id
if (this.params && this.params.hasOwnProperty(name) && undefined !== this.params[name]) {
if (this.params && this.params.hasOwnProperty(name) &&
undefined !== this.params[name]) {
return this.params[name] = value;

@@ -58,4 +59,9 @@ }

// 'login.username' = ['login', 'username']
// For regex matches you can access the parameters using numbers.
if (!Array.isArray(param)) {
param = param.split('.').filter(function(e){return e != '';});
param = typeof param === 'number' ?
[param] :
param.split('.').filter(function(e){
return e !== '';
});
}

@@ -125,3 +131,4 @@

this.str = str;
self.updateParam(param, str); // Replace the param with the filtered version
// Replace the param with the filtered version
self.updateParam(param, str);
};

@@ -128,0 +135,0 @@ return filter.sanitize(this.param(param));

@@ -9,3 +9,3 @@ {

],
"version": "0.2.3",
"version": "0.2.4",
"homepage": "https://github.com/ctavan/express-validator",

@@ -12,0 +12,0 @@ "repository": {

@@ -153,6 +153,22 @@ # express-validator

### Regex routes
Express allows you to define regex routes like:
```javascript
app.get(/\/test(\d+)/, function() {});
```
You can validate the extracted matches like this:
```javascript
req.assert(0, 'Not a three-digit integer.').len(3, 3).isInt();
```
## Changelog
### v0.2.4
- Support for regex routes (@Cecchi)
### v0.2.3

@@ -159,0 +175,0 @@ - Fix checkHeader() (@pimguilherme)

@@ -19,2 +19,3 @@ // Sample app

self.app.get(/\/test(\d+)/, self.validation);
self.app.get('/:testparam?', self.validation);

@@ -21,0 +22,0 @@ self.app.post('/:testparam?', self.validation);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc