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 0.4.0 to 0.4.1

CHANGELOG.md

8

lib/validators.js

@@ -206,1 +206,9 @@ /*jslint node: true */

exports.digits = function (message) {
return exports.regexp(/^\d+$/, message || 'Numbers only.');
};
exports.integer = function (message) {
return exports.regexp(/^-?\d+$/, message || 'Please enter an integer value.');
};

4

package.json

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

"author": "Caolan McMahon",
"version": "0.4.0",
"version": "0.4.1",
"repository": {

@@ -30,3 +30,3 @@ "type": "git",

"testling": "~1.6.1",
"covert": "~0.3.1"
"covert": "~0.4.0"
},

@@ -33,0 +33,0 @@ "licenses": [

@@ -190,2 +190,4 @@ # Forms <sup>[![Version Badge][9]][8]</sup>

* alphanumeric
* digits
* integer

@@ -192,0 +194,0 @@ ### Renderers

@@ -364,1 +364,67 @@ /*jslint node: true */

});
test('integer', function (t) {
var v = validators.integer();
t.test('valid integers', function(st) {
var valids = ['1', '10', '-1', '-10', '-10'];
st.plan(valids.length);
valids.forEach(function (input) {
v('form', { data: input }, function (err) {
st.equal(err, undefined);
});
});
st.end();
});
t.test('invalid integers', function(st) {
var invalids = ['1.5', 'one', '1,5', 'FFFFF', '+10'];
var msg = 'Please enter an integer value.';
st.plan(invalids.length);
invalids.forEach(function (input) {
v('form', { data: input }, function (err) {
st.equal(err, msg);
});
});
st.end();
});
t.end();
});
test('digits', function (t) {
var v = validators.digits();
t.test('valid digits', function(st) {
var valids = ['1', '10', '100'];
st.plan(valids.length);
valids.forEach(function (input) {
v('form', { data: input }, function (err) {
st.equal(err, undefined);
});
});
st.end();
});
t.test('invalid digits', function(st) {
var invalids = ['-1', '+10', 'one', '1.5'];
var msg = 'Numbers only.';
st.plan(invalids.length);
invalids.forEach(function (input) {
v('form', { data: input }, function (err) {
st.equal(err, msg);
});
});
st.end();
});
t.end();
});

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