express-form
Advanced tools
Comparing version 0.9.0 to 0.9.1
@@ -311,2 +311,11 @@ var validator = require("validator") | ||
Field.prototype.isString = function (message) { | ||
return this.add(function (value) { | ||
if (!object.isString(value)) { | ||
return { error: message || "%s is not a string" }; | ||
} | ||
return { valid: true }; | ||
}); | ||
}; | ||
Field.prototype.regex = Field.prototype.is = function (pattern, modifiers, message) { | ||
@@ -313,0 +322,0 @@ // regex(/pattern/) |
@@ -5,3 +5,3 @@ { | ||
"description": "Form validation and data filtering for Express", | ||
"version": "0.9.0", | ||
"version": "0.9.1", | ||
"homepage": "http://dandean.github.com/express-form", | ||
@@ -8,0 +8,0 @@ "repository": { |
@@ -473,2 +473,13 @@ var assert = require("assert"), | ||
}, | ||
'validation : isString()': function() { | ||
var request = { body: { username: 'adasds@example.com', password: { 'somevalue': '1' } }}; | ||
form(validate('password', 'Password') | ||
.required() | ||
.isString() | ||
.minLength(10, '%s must be a minimum of 10 characters') | ||
.maxLength(256, '%s must be a maximum of 256 characters'))(request, {}); | ||
assert.ok(!request.form.isValid); | ||
assert.strictEqual(request.form.errors[0], 'Password is not a string'); | ||
}, | ||
@@ -475,0 +486,0 @@ 'validation : maxLength': function() { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
78182
1716