Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hmpo-form-controller

Package Overview
Dependencies
Maintainers
3
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hmpo-form-controller - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

17

lib/form.js

@@ -21,2 +21,5 @@ var util = require('util'),

this.Error = ErrorClass;
this.formatter = dataFormatter(this.options.fields, this.options.defaultFormatters);
this.validator = dataValidator(this.options.fields);
};

@@ -49,2 +52,3 @@

}
req.form = { values: values || {} };
debug('Rendering form for ' + req.path);

@@ -102,11 +106,6 @@ if (_.isEmpty(this.options.fields) && this.options.next) {

var formatter = dataFormatter(this.options.fields, this.options.defaultFormatters);
var errors = {};
var validator = dataValidator(this.options.fields),
errors = {};
_.each(req.form.values, function (value, key) {
var emptyValue = formatter(key, '');
var error = validator(key, value, req.form.values, emptyValue);
var error = this.validateField(key, req);
if (error) {

@@ -130,2 +129,6 @@ if (error.group) {

},
validateField: function (key, req) {
var emptyValue = this.formatter(key, '');
return this.validator(key, req.form.values[key], req.form.values, emptyValue);
},
_process: function (req, res, callback) {

@@ -132,0 +135,0 @@ req.form = { values: {} };

{
"name": "hmpo-form-controller",
"version": "0.0.2",
"version": "0.0.3",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -143,2 +143,14 @@ var Form = require('../../');

it('sets values to req.form.values', function () {
Form.prototype.getValues.yields(null, { foo: 'bar' });
form.get(req, res, cb);
req.form.values.should.eql({ foo: 'bar' });
});
it('defaults req.form.values to an empty object', function () {
Form.prototype.getValues.yields(null);
form.get(req, res, cb);
req.form.values.should.eql({ });
});
it('calls form.render', function () {

@@ -145,0 +157,0 @@ form.get(req, res, cb);

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