Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Commit

Permalink
Updated dependecy for validator from ~1.5.1 to ~10.3.0. Updated newe… (
Browse files Browse the repository at this point in the history
…#154)

* Updated dependency for validator from ~1.5.1 to ~10.3.0.  

* Updated newer style calls and relaxed new URL check to allow localhost as the earlier version did.

* Bumped version from 1.3.0 to 1.4.0
  • Loading branch information
funkyshu authored Jun 24, 2018
1 parent d7afbfd commit c159904
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
26 changes: 10 additions & 16 deletions lib/plugins/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ var comb = require("comb"),
isIPv4 = net.isIPv4,
isIPv6 = net.isIPv6,
validator = require("validator"),
validatorCheck = validator.check,
dateCmp = comb.date.compare,
isArray = comb.isArray,
combDeepEqual = comb.deepEqual,
Expand Down Expand Up @@ -178,66 +177,61 @@ var Validator = define(null, {

isEmail:function isEmail(opts) {
return this.__addAction(function (col) {
return validatorCheck(col).isEmail();
return validator.isEmail(col);
}, merge({message:"{col} must be a valid Email Address got {val}"}, opts));
},

isUrl:function isUrl(opts) {
return this.__addAction(function (col) {
return validatorCheck(col).isUrl();
return !!col.match(/^(?:https?|ftp):\/\/localhost/) || validator.isURL(col);
}, merge({message:"{col} must be a valid url got {val}"}, opts));
},

isAlpha:function isAlpha(opts) {
return this.__addAction(function (col) {
return validatorCheck(col).isAlpha();
return validator.isAlpha(col);
}, merge({message:"{col} must be a only letters got {val}"}, opts));
},

isAlphaNumeric:function isAlphaNumeric(opts) {
return this.__addAction(function (col) {
return validatorCheck(col).isAlphanumeric();
return validator.isAlphanumeric(col);
}, merge({message:"{col} must be a alphanumeric got {val}"}, opts));
},

hasLength:function hasLength(min, max, opts) {
return this.__addAction(function (col) {
return validatorCheck(col).len(min, max);
return validator.isLength(col, {min: min, max: max});
}, merge({message:"{col} must have a length between " + min + (max ? " and " + max : "") + "."}, opts));
},

isLowercase:function isLowercase(opts) {
return this.__addAction(function (col) {
return validatorCheck(col).isLowercase();
return validator.isLowercase(col);
}, merge({message:"{col} must be lowercase got {val}."}, opts));
},

isUppercase:function isUppercase(opts) {
return this.__addAction(function (col) {
return validatorCheck(col).isUppercase();
return validator.isUppercase(col);
}, merge({message:"{col} must be uppercase got {val}."}, opts));
},

isEmpty:function isEmpty(opts) {
return this.__addAction(function (col) {
try {
validatorCheck(col).notEmpty();
return false;
} catch (e) {
return true;
}
return validator.isEmpty(col);
}, merge({message:"{col} must be empty got {val}."}, opts));
},

isNotEmpty:function isNotEmpty(opts) {
return this.__addAction(function (col) {
return validatorCheck(col).notEmpty();
return !validator.isEmpty(col);
}, merge({message:"{col} must not be empty."}, opts));
},

isCreditCard:function isCreditCard(opts) {
return this.__addAction(function (col) {
return validatorCheck(col).isCreditCard();
return validator.isCreditCard(col);
}, merge({message:"{col} is an invalid credit card"}, opts));
},

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "patio",
"description": "Patio query engine and ORM",
"version": "1.3.0",
"version": "1.4.0",
"keywords": [
"ORM",
"object relation mapper",
Expand Down Expand Up @@ -38,7 +38,7 @@
"pg": "4.4.3",
"pg-query-stream": "1.0.0",
"pg-types": "1.10.0",
"validator": "~1.5.1"
"validator": "~10.3.0"
},
"scripts": {
"test": "grunt test"
Expand Down

0 comments on commit c159904

Please sign in to comment.