Comparing version 1.0.0 to 1.0.2
1.0.2 / 2015-01-12 | ||
================== | ||
* feat: add url | ||
* fix: remove david badge | ||
1.0.1 / 2015-01-09 | ||
================== | ||
* fix(readme): fix exmaple arguments | ||
1.0.0 / 2015-01-09 | ||
@@ -3,0 +14,0 @@ ================== |
31
index.js
@@ -35,2 +35,5 @@ /** | ||
// https://gist.github.com/dperini/729294 | ||
var URL_RE = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/\S*)?$/i; | ||
/** | ||
@@ -57,2 +60,3 @@ * Simple type map | ||
password: checkPassword, | ||
url: checkUrl, | ||
}; | ||
@@ -345,2 +349,3 @@ | ||
*/ | ||
function checkEmail(rule, value) { | ||
@@ -353,2 +358,12 @@ return checkString({ | ||
/** | ||
* check password | ||
* @param {Object} rule | ||
* @param {Object} value | ||
* @param {Object} obj | ||
* @return {Boolean} | ||
* | ||
* @api private | ||
*/ | ||
function checkPassword(rule, value, obj) { | ||
@@ -369,2 +384,18 @@ if (!rule.min) { | ||
/** | ||
* check url | ||
* | ||
* @param {Object} rule | ||
* @param {Object} value | ||
* @return {Boolean} | ||
* @api private | ||
*/ | ||
function checkUrl(rule, value) { | ||
return checkString({ | ||
format: URL_RE, | ||
message: rule.message || 'should be a url' | ||
}, value); | ||
} | ||
/** | ||
* check object | ||
@@ -371,0 +402,0 @@ * { |
{ | ||
"name": "parameter", | ||
"version": "1.0.0", | ||
"version": "1.0.2", | ||
"description": "A parameter verify tools.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -7,3 +7,2 @@ parameter | ||
[![Test coverage][coveralls-image]][coveralls-url] | ||
[![David deps][david-image]][david-url] | ||
[![node version][node-image]][node-url] | ||
@@ -17,4 +16,2 @@ | ||
[coveralls-url]: https://coveralls.io/r/node-modules/parameter?branch=master | ||
[david-image]: https://img.shields.io/david/node-modules/parameter.svg?style=flat-square | ||
[david-url]: https://david-dm.org/node-modules/parameter | ||
[node-image]: https://img.shields.io/badge/node.js-%3E=_0.10-green.svg?style=flat-square | ||
@@ -57,3 +54,3 @@ [node-url]: http://nodejs.org/download/ | ||
var errors = validate(data, rule); | ||
var errors = validate(rule, data); | ||
``` | ||
@@ -135,2 +132,6 @@ | ||
#### url | ||
The `url` type want to match [web url](https://gist.github.com/dperini/729294). | ||
#### enum | ||
@@ -172,3 +173,2 @@ | ||
- `/\d+/` => `{type: 'string', required: true, allowEmpty: false, format: /\d+/}` | ||
``` | ||
@@ -175,0 +175,0 @@ ## `errors` examples |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
17898
418
0