New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

koa-validator

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-validator - npm Package Compare versions

Comparing version 0.5.0 to 0.5.2

2

lib/extend.js

@@ -62,3 +62,3 @@ var validator = require('validator')

// validator.js will convert the first param to string
if(d === ''){
if(d === '' && value !== undefined){
return value;

@@ -65,0 +65,0 @@ }else{

{
"name": "koa-validator",
"version": "0.5.0",
"version": "0.5.2",
"description": "a koa port of express-validator",

@@ -16,3 +16,2 @@ "main": "index.js",

"devDependencies": {
"async": "^0.9.0",
"chai": "^1.9.1",

@@ -19,0 +18,0 @@ "koa": "^0.10.0",

@@ -5,3 +5,2 @@ var koa = require('koa')

, router = require('koa-router')
, async = require('async')

@@ -20,3 +19,5 @@ , validator = require('..')

it("these validates should be to ok" , function(done){
var app = createApp();
var app = createApp()
, errors
;
app.post('/validate',function*(){

@@ -72,4 +73,4 @@ this.checkBody('name').notEmpty().len(3,20);

this.checkBody('sp').isSurrogatePair();
if(this._validationErrors){
this.body = this._validationErrors;
if(errors = this.validationErrors()){
this.body = errors;
return;

@@ -132,3 +133,5 @@ }

it("these validates fail tests should be to ok" , function(done){
var app = createApp();
var app = createApp()
, errors
;
app.post('/validate',function*(){

@@ -183,8 +186,16 @@ this.checkBody('name').notEmpty().len(3,20);

this.checkBody('sp').isSurrogatePair();
if(this._validationErrors.length === 48){
this.body = this._validationErrors;
this.body = 'ok';
return ;
errors = this.validationErrors();
if(errors){
if(errors.length === 48){
this.body = 'ok';
return;
}else{
this.body = 'only ' + errors.length + ' errors';
return;
}
}else{
this.body = 'there is no error';
return;
}
this.body= 'only '+this._validationErrors.length+' errors';
});

@@ -244,8 +255,10 @@ var req = request(app.listen());

it('there validate query should be to okay' , function(done){
var app = createApp();
var app = createApp()
, errors
;
app.get('/query',function*(){
this.checkQuery('name').notEmpty();
this.checkQuery('password').len(3,20);
if(this.errors){
this.body = this.errors;
if(errors = this.validationErrors()){
this.body = errors;
return;

@@ -265,7 +278,9 @@ }

it('there validate params should be to okay' , function(done){
var app = createApp();
var app = createApp()
, errors
;
app.get('/:id',function*(){
this.checkParams('id').isInt();
if(this._validationErrors){
this.body = this._validationErrors;
if(errors = this.validationErrors()){
this.body = errors;
return;

@@ -272,0 +287,0 @@ }

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