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

express-form

Package Overview
Dependencies
Maintainers
0
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-form - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

2

._index.js

@@ -1,4 +0,4 @@

Mac OS X  2��ATTR�#���!�!com.macromates.caret{
Mac OS X  2��ATTR�����!�!com.macromates.caret{
column = 0;
line = 1;
}

@@ -1,4 +0,4 @@

Mac OS X  2��ATTR�#���"�"com.macromates.caret{
column = 19;
Mac OS X  2��ATTR�����"�"com.macromates.caret{
column = 17;
line = 3;
}

@@ -1,4 +0,4 @@

Mac OS X  2��ATTR�#���#�#com.macromates.caret{
column = 61;
line = 36;
Mac OS X  2��ATTR�����$�$com.macromates.caret{
column = 41;
line = 239;
}

@@ -1,4 +0,4 @@

Mac OS X  2��ATTR�#���"�"com.macromates.caret{
column = 0;
line = 34;
Mac OS X  2��ATTR�����#�#com.macromates.caret{
column = 79;
line = 23;
}

@@ -1,4 +0,4 @@

Mac OS X  2��ATTR�#���"�"com.macromates.caret{
Mac OS X  2��ATTR�����"�"com.macromates.caret{
column = 0;
line = 13;
}

@@ -1,4 +0,4 @@

Mac OS X  2��ATTR�#���"�"com.macromates.caret{
column = 37;
line = 0;
Mac OS X  2��ATTR�����#�#com.macromates.caret{
column = 43;
line = 42;
}

@@ -1,4 +0,4 @@

Mac OS X  2��ATTR�#���#�#com.macromates.caret{
column = 61;
line = 56;
}
Mac OS X  2#UATTR���U���#com.macromates.caret�vcom.macromates.foldings{
column = 30;
line = 71;
}x���R��j8+�(?W�V���.�����W4@����f&�Z�Ya��9a�,�1Ȓ� �0��ؐ����1�̘��L�1ʜW��*sK"�� *���?C Kb��� �&U��x

@@ -13,2 +13,4 @@ var validator = require("validator"),

var dataSources = ["body", "query", "params"];
function form() {

@@ -22,3 +24,3 @@ var routines = Array.prototype.slice.call(arguments);

["body", "query", "params"].forEach(function(source) {
dataSources.forEach(function(source) {
if (req[source] && !object.isString(req[source])) {

@@ -59,2 +61,17 @@ Object.keys(req[source]).forEach(function(name) {

form.configure = function(options) {
if (options) {
if ("dataSources" in options) {
dataSources = [];
var sources = options.dataSources;
if (object.isString(sources)) {
dataSources.push(sources);
} else if (Array.isArray(sources)) {
sources.forEach(function(source) { dataSources.push(source); });
}
}
}
return this;
};
module.exports = form;

@@ -20,2 +20,7 @@ var validator = require("validator"),

stack.forEach(function(validate) {
validate.getValue = function(name) {
return formData[name];
};
try {

@@ -34,3 +39,3 @@ validate(formData[fieldname]);

Object.keys(ValidatorPrototype).forEach(function(name) {
if (name.match(/^(check|validate|assert|error|len|isNumeric|isDecimal|isFloat|regex|notRegex|is|not)$/))
if (name.match(/^(equals|check|validate|assert|error|len|isNumeric|isDecimal|isFloat|regex|notRegex|is|not)$/))
return;

@@ -64,2 +69,15 @@

Validator.prototype.equals = function(other, message) {
return this.add(function(value) {
// If other is a field token (field::fieldname), grab the value of fieldname
// and use that as the OTHER value.
if (object.isString(other) && other.match(/^field::/)) {
other = arguments.callee.getValue(other.replace(/^field::/, ''));
}
if (value != other) {
throw new Error(message || "Not equal");
}
});
};
// node-validator's numeric validator seems unintuitive. All numeric values should be valid, not just int.

@@ -66,0 +84,0 @@ Validator.prototype.isNumeric = function(message) {

{
"name": "express-form",
"description": "Form validation and data filtering for Express",
"version": "0.2.0",
"version": "0.3.0",
"homepage": "https://github.com/dandean/express-form",

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

@@ -232,3 +232,4 @@ Express Form provides data filtering and validation as route middleware to your Express applications.

equals( value [, message] )
- value (String): A value that should match the field value.
- value (String): A value that should match the field value OR a fieldname
token to match another field, ie, `field::password`.

@@ -240,3 +241,6 @@ Compares the field to `value`.

validate("password").is(/^\w{6,20}$/)
validate("password_confirmation").equals("field::password")
contains(value[, message])

@@ -243,0 +247,0 @@ - value (String): The value to test for.

@@ -1,4 +0,4 @@

Mac OS X  2��ATTR�#���"�"com.macromates.caret{
column = 4;
line = 13;
Mac OS X  2��ATTR�����#�#com.macromates.caret{
column = 52;
line = 26;
}

@@ -1,4 +0,7 @@

Mac OS X  2��ATTR�#���#�#com.macromates.caret{
column = 24;
line = 75;
}
Mac OS X  2 RATTR���R���#com.macromates.caret�scom.macromates.foldings{
column = 0;
line = 306;
}x��б
�0 н_�Q���������
�&�w�nr��G2c�9�6n�l;+�iS6-���WZ}پ�W�'��%�������$(-)
BPC����2Tp����VpL+���h�k�t=

@@ -19,3 +19,14 @@ var assert = require("assert"),

assert.strictEqual(request.form.isValid, true);
},
'form : configure : dataSources': function() {
form.configure({ dataSources: 'other' });
var request = { other: { field: "me@dandean.com" }};
form(validate("field").isEmail())(request, {});
assert.strictEqual(request.form.isValid, true);
assert.equal(request.form.field, "me@dandean.com");
form.configure({ dataSources: ['body', "query", "params"] });
}
};

@@ -295,2 +295,24 @@ var assert = require("assert"),

assert.equal(request.form.errors, undefined);
// Failure
var request = {
body: {
field1: "value1",
field2: "value2"
}
};
form(validate("field1").equals("field::field2"))(request, {});
assert.equal(request.form.errors.length, 1);
assert.equal(request.form.errors[0], "Not equal");
// Success
var request = {
body: {
field1: "value",
field2: "value"
}
};
form(validate("field1").equals("field::field2"))(request, {});
assert.equal(request.form.errors, undefined);
},

@@ -526,3 +548,3 @@

assert.equal(request.form.errors, undefined);
},
}
};

@@ -8,10 +8,2 @@ TODO

### request.form values
Precedence: url param -> query param -> request body
TODO: check how this compares to other solutions: rails, zend, django, .net.
TODO: how does this work with request.param() ? May need to override that so
to ensure that it pulls form request.form.
### Configurability

@@ -33,2 +25,3 @@

* auto-locals
* Do not assume data is a String. May need to drop `node-validator` dependency.

@@ -35,0 +28,0 @@

Sorry, the diff of this file is not supported yet

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