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

forms

Package Overview
Dependencies
Maintainers
2
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

forms - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

23

CHANGELOG.md

@@ -0,1 +1,12 @@

1.1.0 / 2014-12-16
===================
* Use label text instead of field name consistently in error messages
* Fix support of zero values in inputs (#147)
* Update `qs`, `is`, `object.assign`, `tape`, `covert`, `jscs`
1.0.0 / 2014-09-29
===================
* v1.0.0 - it’s time.
* Update CHANGELOG
0.10.0 / 2014-09-24

@@ -83,3 +94,3 @@ ===================

Relates to [#82](https://github.com/caolan/forms/issues/82).
* Removing the express example, primarily because it doesn't work with express 3. Also, the dependency stuff is weird.
* Removing the express example, primarily because it doesn’t work with express 3. Also, the dependency stuff is weird.
This should go in a separate repo rather than living inside `forms`.

@@ -89,3 +100,3 @@ Closes [#93](https://github.com/caolan/forms/issues/93). Relates to [#105](https://github.com/caolan/forms/issues/105).

Made `%s` string formatting tokens optional in field validator error messages.
* Oops! Make sure we're running all tests
* Oops! Make sure we’re running all tests
* Made `%s` string formatting tokens optional in field validator error messages.

@@ -96,3 +107,3 @@ * Add number widget.

* Updating json-template.
Note: it can't be installed from npm because the package.json is invalid.
Note: it can’t be installed from npm because the package.json is invalid.
* Merge pull request [#101](https://github.com/caolan/forms/issues/101) from caolan/use_tape_for_tests

@@ -133,3 +144,3 @@ Use tape for tests

* Updating browserify.
* Merge branch 'required_validator'. Closes [#81](https://github.com/caolan/forms/issues/81).
* Merge branch "required_validator". Closes [#81](https://github.com/caolan/forms/issues/81).
* Use String() instead of the toString prototype method.

@@ -153,3 +164,3 @@ * When the "required" option is true, use the default "required" validator. Otherwise, use the passed-in validator.

* s/\t/ /g
* Merge branch 'nested_fields_merge' - merges [#77](https://github.com/caolan/forms/issues/77), fixes [#11](https://github.com/caolan/forms/issues/11)
* Merge branch "nested_fields_merge" - merges [#77](https://github.com/caolan/forms/issues/77), fixes [#11](https://github.com/caolan/forms/issues/11)
* Using arguments.length to shift arguments.

@@ -184,4 +195,4 @@ * Adding spacing.

* take object literals as nested fields
* Adding ES5's String#trim
* Adding ES5’s String#trim
* Removing an extra space
* compatibility

@@ -14,4 +14,4 @@ /*

var coerceToString = function (val) {
return String(val || '');
var coerceToString = function (value) {
return typeof value === 'undefined' || value === null ? '' : String(value);
};

@@ -18,0 +18,0 @@

@@ -15,2 +15,13 @@ /*jslint node: true */

var formatFieldName = function formatFieldName(field) {
var defaultFieldName = 'This field';
//in regular use, labelText is a defined function, but it's not when running tests.
if (typeof field.labelText === 'function') {
return field.name ? field.labelText(field.name) : defaultFieldName;
} else {
return field.name || defaultFieldName;
}
}
// From https://github.com/kriskowal/es5-shim/blob/master/es5-shim.js#L1238-L1257

@@ -47,3 +58,3 @@ var trim = (function () {

if (field.data !== expected) {
callback(format(message, field.name || 'This field', expected));
callback(format(message, formatFieldName(field), expected));
} else {

@@ -59,3 +70,3 @@ callback();

if (trim(field.data).length === 0) {
callback(format(message, field.name || 'This field'));
callback(format(message, formatFieldName(field)));
} else {

@@ -73,3 +84,3 @@ callback();

if (alternateBlank && fieldBlank) {
callback(format(message, field.name, alternate_field));
callback(format(message, formatFieldName(field), alternate_field));
} else {

@@ -76,0 +87,0 @@ callback();

@@ -29,3 +29,3 @@ /*jslint node: true */

formatValue: function (value) {
return value || null;
return (value || value === 0) ? value : null;
}

@@ -32,0 +32,0 @@ };

@@ -6,3 +6,3 @@ {

"author": "Caolan McMahon",
"version": "1.0.0",
"version": "1.1.0",
"repository": {

@@ -24,12 +24,12 @@ "type": "git",

"async": "~0.9.0",
"qs": "~2.2.4",
"qs": "~2.3.3",
"formidable": "~1.0.15",
"is": "~2.0.1",
"object.assign": "~1.0.1"
"is": "~2.2.0",
"object.assign": "~1.1.1"
},
"devDependencies": {
"tape": "~3.0.0",
"tape": "~3.0.3",
"testling": "~1.7.1",
"covert": "~1.0.0",
"jscs": "~1.6.2"
"covert": "1.0.0",
"jscs": "~1.8.1"
},

@@ -36,0 +36,0 @@ "license": "MIT",

@@ -145,5 +145,9 @@ # Forms <sup>[![Version Badge][npm-version-svg]][npm-url]</sup>

var label = object.labelHTML(name);
var error = object.error ? '<div class="alert alert-error">' + object.error + '</div>' : '';
var error = object.error ? '<div class="alert alert-error help-block">' + object.error + '</div>' : '';
var validationclass = object.value && !object.error ? 'has-success' : '';
validationclass = object.error ? 'has-error' : validationclass;
var widget = object.widget.toHTML(name, object);
return '<div class="form-group">' + label + widget + error + '</div>';
return '<div class="form-group ' + validationclass + '">' + label + widget + error + '</div>';
};

@@ -150,0 +154,0 @@ ```

@@ -102,5 +102,6 @@ /*jslint node: true */

field1: forms.fields.string(),
field2: forms.fields.string()
field2: forms.fields.string(),
field3: forms.fields.string()
});
f.bind({field1: '1', field2: '2'}).validate(function (err, f) {
f.bind({field1: '1', field2: '2', field3: 0}).validate(function (err, f) {
t.true(f.isValid());

@@ -116,2 +117,6 @@ t.equal(

'<input type="text" name="field2" id="id_field2" value="2" />' +
'</div>' +
'<div class="field">' +
'<label for="id_field3">Field3</label>' +
'<input type="text" name="field3" id="id_field3" value="0" />' +
'</div>'

@@ -393,3 +398,3 @@ );

t.equal(form.fields.field1.error, undefined);
t.equal(form.fields.field2.error, 'field2 is required.');
t.equal(form.fields.field2.error, 'Field2 is required.');
t.equal(form.fields.field3.error, undefined);

@@ -414,4 +419,4 @@ t.end();

t.equal(form.fields.field1.error, undefined);
t.equal(form.fields.field2.error, 'field2 is required.');
t.equal(form.fields.field3.error, 'field3 is required.');
t.equal(form.fields.field2.error, 'Field2 is required.');
t.equal(form.fields.field3.error, 'Field3 is required.');
t.end();

@@ -418,0 +423,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