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

validate.js

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

validate.js - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

2

bower.json
{
"name": "validate.js",
"main": ["validate.js", "validate.min.js"],
"version": "0.3.0",
"version": "0.3.1",
"ignore": [

@@ -6,0 +6,0 @@ "**/.*",

@@ -98,3 +98,3 @@ module.exports = function(grunt) {

'// http://validatejs.org/\n' +
'// (c) 2013 Wrapp\n' +
'// (c) 2014 Wrapp\n' +
'// <%= pkg.name %> may be freely distributed under the MIT license.\n'

@@ -101,0 +101,0 @@ },

The MIT License (MIT)
Copyright (c) 2013-2014 Wrapp, Nicklas Ansman
Copyright (c) 2013-2014 Nicklas Ansman, Wrapp

@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

{
"name": "validate.js",
"version": "0.3.0",
"version": "0.3.1",
"author": "Nicklas Ansman <nicklas@ansman.se>",

@@ -5,0 +5,0 @@ "description": "Declarative validations for JavaScript",

1. Bump the version in package.json
3. Bump the version bower.json
4. Bump the version validate.js
4. Bump the version index.html (sidebar link and all links with the old version)
2. Bump the version bower.json
3. Bump the version validate.js
4. Bump the version index.html (sidebar link and all links with the old version, search for the old version)
5. Compile with `grunt build`
6. Publish with npm: `npm publish`
6. Commit with message "Release version X.X.X"
7. Tag using `git tag -a` with message "X.X.X"
8. Publish with npm using `npm publish`

@@ -18,5 +18,5 @@ describe('validators.datetime', function() {

it("throws and error if neither XDate or moment.js is found", function() {
window.XDate = null;
spyOn(validate, 'tryRequire').andReturn(null);
expect(function() {
delete window.XDate;
spyOn(validate.tryRequire).andReturn(null);
parse("2014-09-02");

@@ -79,2 +79,10 @@ }).toThrow();

it("throws and error if neither XDate or moment.js is found", function() {
window.XDate = null;
spyOn(validate, 'tryRequire').andReturn(null);
expect(function() {
format(1382808924000, {});
}).toThrow();
});
function runDatetimeTest() {

@@ -269,2 +277,8 @@ var expected = "2013-10-26 17:35:24";

});
it("calls the datetime validator with the right context", function() {
spyOn(validate.validators, 'datetime');
validate.validators.date("foo", {});
expect(validate.validators.datetime).toHaveBeenCalledWithContext(validate.validators.datetime);
});
});

@@ -1,3 +0,3 @@

// Validate.js 0.3.0
// (c) 2014 Wrapp
// Validate.js 0.3.1
// (c) 2013-2014 Nicklas Ansman, Wrapp
// Validate.js may be freely distributed under the MIT license.

@@ -683,3 +683,3 @@ // For all details and documentation:

options = v.extend({}, options, {onlyDate: true});
return v.validators.datetime(value, options);
return v.validators.datetime.call(v.validators.datetime, value, options);
},

@@ -686,0 +686,0 @@ format: function(value, options) {

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

// validate.js 0.3.0
// validate.js 0.3.1
// http://validatejs.org/
// (c) 2013 Wrapp
// (c) 2014 Wrapp
// validate.js may be freely distributed under the MIT license.
(function(a,b,c,d){"use strict";var e=function(a,b,c){c=c||{};var d,g,h=f.runValidations(a,b,c);for(d in h)for(g in h[d])if(f.isPromise(h[d][g]))throw new Error("Use validate.async if you want support for promises");return e.processValidationResults(h,c)},f=e,g=this,h=/%\{([^\}]+)\}/g;f.extend=function(a){return[].slice.call(arguments,1).forEach(function(b){for(var c in b)a[c]=b[c]}),a},f.extend(e,{runValidations:function(a,b){var c,d,e,g,h,i,j,k=[];for(c in b){e=f.getDeepObjectValue(a,c),g=f.result(b[c],e,a,c);for(d in g){if(h=f.validators[d],!h)throw j=f.format("Unknown validator %{name}",{name:d}),new Error(j);i=g[d],i=f.result(i,e,a,c),i&&k.push({attribute:c,error:h.call(h,e,i,c,a)})}}return k},processValidationResults:function(a,b){var c={};a.forEach(function(a){var b=a.error,d=a.attribute;f.isString(b)&&(b=[b]),b&&(c[d]=(c[d]||[]).concat(b))});for(var d in c)return f.fullMessages(c,b)},async:function(a,b,c){c=c||{};var d=f.runValidations(a,b,c);return f.Promise(function(a,b){f.waitForResults(d).then(function(){var c=f.processValidationResults(d);c?b(c):a()}).then(void 0,f.error)})},waitForResults:function(a){var b=a.reduce(function(a,b){return f.isPromise(b.error)?a.then(function(){return b.error.then(function(){b.error=null},function(a){a||f.warn("Validator promise was rejected but didn't return an error"),b.error=a}).then(void 0,f.error)}).then(void 0,f.error):a},f.Promise(function(a){a()}));return b.then(void 0,f.error)},result:function(a){var b=[].slice.call(arguments,1);return"function"==typeof a&&(a=a.apply(null,b)),a},isNumber:function(a){return"number"==typeof a&&!isNaN(a)},isFunction:function(a){return"function"==typeof a},isInteger:function(a){return f.isNumber(a)&&a%1===0},isObject:function(a){return a===Object(a)},isDefined:function(a){return null!==a&&void 0!==a},isPromise:function(a){return!!a&&"function"==typeof a.then},format:function(a,b){return a.replace(h,function(a,c){return String(b[c])})},prettify:function(a){return a.replace(/([^\s])\.([^\s])/g,"$1 $2").replace(/\\+/g,"").replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,function(a,b,c){return""+b+" "+c.toLowerCase()}).toLowerCase()},isString:function(a){return"string"==typeof a},isArray:function(a){return"[object Array]"==={}.toString.call(a)},contains:function(a,b){return f.isDefined(a)?f.isArray(a)?-1!==a.indexOf(b):b in a:!1},getDeepObjectValue:function(a,b){if(!f.isObject(a)||!f.isString(b))return void 0;var c,d="",e=!1;for(c=0;c<b.length;++c)switch(b[c]){case".":if(e)e=!1,d+=".";else{if(!(d in a))return void 0;a=a[d],d=""}break;case"\\":e?(e=!1,d+="\\"):e=!0;break;default:e=!1,d+=b[c]}return d in a?a[d]:void 0},capitalize:function(a){return f.isString(a)?a[0].toUpperCase()+a.slice(1):a},fullMessages:function(a,b){function c(a,c){c.forEach(function(c){"^"===c[0]?c=c.slice(1):b.fullMessages!==!1&&(c=f.format("%{attr} %{message}",{attr:f.capitalize(f.prettify(a)),message:c})),c=c.replace(/\\\^/g,"^"),b.flatten?e.push(c):(e[a]||(e[a]=[])).push(c)})}b=b||{};var d,e=b.flatten?[]:{};if(!a)return e;for(d in a)c(d,a[d]);return e},Promise:f.extend(function(a){var b=f.Promise.nativePromise(a)||f.Promise.RSVPPromise(a)||f.Promise.whenPromise(a)||f.Promise.QPromise(a);if(!b)throw new Error("No promises could be detected");return b},{nativePromise:function(a){var b,c;return"undefined"!=typeof Promise?b=Promise:(c=f.tryRequire("es6-promise"),c&&(b=c.Promise)),b?new b(a):void 0},RSVPPromise:function(a){var b,c;return"undefined"!=typeof RSVP?b=RSVP.Promise:(c=f.tryRequire("rsvp"),c&&(b=c.Promise)),b?new b(a):void 0},whenPromise:function(a){var b,c;return"undefined"!=typeof when?b=when.promise:(c=f.tryRequire("when"),c&&(b=c.promise)),b?b(a):void 0},QPromise:function(a){var b,c;return"undefined"!=typeof Q?b=Q.promise:(c=f.tryRequire("q"),c&&(b=c.promise)),b?b(a):void 0}}),tryRequire:function(a){if(!f.require)return null;try{return f.require(a)}catch(b){return null}},require:d,exposeModule:function(a,b,c,d,e){c?(d&&d.exports&&(c=d.exports=a),c.validate=a):(b.validate=a,a.isFunction(e)&&e.amd&&e("validate",[],function(){return a}))},warn:function(a){"undefined"!=typeof console&&console.warn&&console.warn(a)},error:function(a){"undefined"!=typeof console&&console.error&&console.error(a)}}),e.validators={presence:function(a,b){var c,d=b.message||"can't be blank";if(!f.isDefined(a))return d;if(!f.isFunction(a))if("string"==typeof a){if(/^\s*$/.test(a))return d}else if(f.isArray(a)){if(0===a.length)return d}else if(f.isObject(a)){for(c in a)return;return d}},length:function(a,b){if(f.isDefined(a)){var c,d=b.is,e=b.maximum,g=b.minimum,h=b.tokenizer||function(a){return a},i=[];return a=h(a),f.isNumber(d)&&a.length!==d&&(c=b.wrongLength||"is the wrong length (should be %{count} characters)",i.push(f.format(c,{count:d}))),f.isNumber(g)&&a.length<g&&(c=b.tooShort||"is too short (minimum is %{count} characters)",i.push(f.format(c,{count:g}))),f.isNumber(e)&&a.length>e&&(c=b.tooLong||"is too long (maximum is %{count} characters)",i.push(f.format(c,{count:e}))),i.length>0?b.message||i:void 0}},numericality:function(a,b){if(f.isDefined(a)){var c,d,e=[],g={greaterThan:function(a,b){return a>b},greaterThanOrEqualTo:function(a,b){return a>=b},equalTo:function(a,b){return a===b},lessThan:function(a,b){return b>a},lessThanOrEqualTo:function(a,b){return b>=a}};if(b.noStrings!==!0&&f.isString(a)&&(a=+a),!f.isNumber(a))return b.message||"is not a number";if(b.onlyInteger&&!f.isInteger(a))return b.message||"must be an integer";for(c in g)d=b[c],f.isNumber(d)&&!g[c](a,d)&&e.push(f.format("must be %{type} %{count}",{count:d,type:f.prettify(c)}));return b.odd&&a%2!==1&&e.push("must be odd"),b.even&&a%2!==0&&e.push("must be even"),e.length?b.message||e:void 0}},datetime:f.extend(function(a,b){if(f.isDefined(a)){var c,d=[],e=b.message,g=b.earliest?this.parse(b.earliest,b):0/0,h=b.latest?this.parse(b.latest,b):0/0;return a=this.parse(a,b),isNaN(a)||b.dateOnly&&a%864e5!==0?e||"must be a valid date":(!isNaN(g)&&g>a&&(c="must be no earlier than %{date}",c=f.format(c,{date:this.format(g,b)}),d.push(c)),!isNaN(h)&&a>h&&(c="must be no later than %{date}",c=f.format(c,{date:this.format(h,b)}),d.push(c)),d.length?b.message||d:void 0)}},{parse:function(a){if(f.isFunction(g.XDate))return new g.XDate(a,!0).getTime();var b=f.tryRequire("moment");if(f.isDefined(b))return+b.utc(a);throw new Error("Neither XDate or moment.js was found")},format:function(a,b){var c=b.dateFormat;if(f.isFunction(g.XDate))return c=c||(b.dateOnly?"yyyy-MM-dd":"yyyy-MM-dd HH:mm:ss"),new XDate(a,!0).toString(c);var d=f.tryRequire("moment");if(f.isDefined(d))return c=c||(b.dateOnly?"YYYY-MM-DD":"YYYY-MM-DD HH:mm:ss"),d.utc(a).format(c);throw new Error("Neither XDate or moment.js was found")}}),date:function(a,b){return b=f.extend({},b,{onlyDate:!0}),f.validators.datetime(a,b)},format:function(a,b){(f.isString(b)||b instanceof RegExp)&&(b={pattern:b});var c,d=b.message||"is invalid",e=b.pattern;if(f.isDefined(a))return f.isString(a)?(f.isString(e)&&(e=new RegExp(b.pattern,b.flags)),c=e.exec(a),c&&c[0].length==a.length?void 0:d):d},inclusion:function(a,b){if(f.isArray(b)&&(b={within:b}),f.isDefined(a)&&!f.contains(b.within,a)){var c=b.message||"^%{value} is not included in the list";return f.format(c,{value:a})}},exclusion:function(a,b){if(f.isArray(b)&&(b={within:b}),f.isDefined(a)&&f.contains(b.within,a)){var c=b.message||"^%{value} is restricted";return f.format(c,{value:a})}},email:f.extend(function(a,b){var c=b.message||"is not a valid email";if(f.isDefined(a))return f.isString(a)&&this.PATTERN.exec(a)?void 0:c},{PATTERN:/^[a-z0-9\u007F-\uffff!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9\u007F-\uffff!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}$/i})},e.exposeModule(e,g,a,b,c)}).call(this,"undefined"!=typeof exports?exports:null,"undefined"!=typeof module?module:null,"undefined"!=typeof define?define:null,"undefined"!=typeof require?require:null);
(function(a,b,c,d){"use strict";var e=function(a,b,c){c=c||{};var d,g,h=f.runValidations(a,b,c);for(d in h)for(g in h[d])if(f.isPromise(h[d][g]))throw new Error("Use validate.async if you want support for promises");return e.processValidationResults(h,c)},f=e,g=this,h=/%\{([^\}]+)\}/g;f.extend=function(a){return[].slice.call(arguments,1).forEach(function(b){for(var c in b)a[c]=b[c]}),a},f.extend(e,{runValidations:function(a,b){var c,d,e,g,h,i,j,k=[];for(c in b){e=f.getDeepObjectValue(a,c),g=f.result(b[c],e,a,c);for(d in g){if(h=f.validators[d],!h)throw j=f.format("Unknown validator %{name}",{name:d}),new Error(j);i=g[d],i=f.result(i,e,a,c),i&&k.push({attribute:c,error:h.call(h,e,i,c,a)})}}return k},processValidationResults:function(a,b){var c={};a.forEach(function(a){var b=a.error,d=a.attribute;f.isString(b)&&(b=[b]),b&&(c[d]=(c[d]||[]).concat(b))});for(var d in c)return f.fullMessages(c,b)},async:function(a,b,c){c=c||{};var d=f.runValidations(a,b,c);return f.Promise(function(a,b){f.waitForResults(d).then(function(){var c=f.processValidationResults(d);c?b(c):a()}).then(void 0,f.error)})},waitForResults:function(a){var b=a.reduce(function(a,b){return f.isPromise(b.error)?a.then(function(){return b.error.then(function(){b.error=null},function(a){a||f.warn("Validator promise was rejected but didn't return an error"),b.error=a}).then(void 0,f.error)}).then(void 0,f.error):a},f.Promise(function(a){a()}));return b.then(void 0,f.error)},result:function(a){var b=[].slice.call(arguments,1);return"function"==typeof a&&(a=a.apply(null,b)),a},isNumber:function(a){return"number"==typeof a&&!isNaN(a)},isFunction:function(a){return"function"==typeof a},isInteger:function(a){return f.isNumber(a)&&a%1===0},isObject:function(a){return a===Object(a)},isDefined:function(a){return null!==a&&void 0!==a},isPromise:function(a){return!!a&&"function"==typeof a.then},format:function(a,b){return a.replace(h,function(a,c){return String(b[c])})},prettify:function(a){return a.replace(/([^\s])\.([^\s])/g,"$1 $2").replace(/\\+/g,"").replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,function(a,b,c){return""+b+" "+c.toLowerCase()}).toLowerCase()},isString:function(a){return"string"==typeof a},isArray:function(a){return"[object Array]"==={}.toString.call(a)},contains:function(a,b){return f.isDefined(a)?f.isArray(a)?-1!==a.indexOf(b):b in a:!1},getDeepObjectValue:function(a,b){if(!f.isObject(a)||!f.isString(b))return void 0;var c,d="",e=!1;for(c=0;c<b.length;++c)switch(b[c]){case".":if(e)e=!1,d+=".";else{if(!(d in a))return void 0;a=a[d],d=""}break;case"\\":e?(e=!1,d+="\\"):e=!0;break;default:e=!1,d+=b[c]}return d in a?a[d]:void 0},capitalize:function(a){return f.isString(a)?a[0].toUpperCase()+a.slice(1):a},fullMessages:function(a,b){function c(a,c){c.forEach(function(c){"^"===c[0]?c=c.slice(1):b.fullMessages!==!1&&(c=f.format("%{attr} %{message}",{attr:f.capitalize(f.prettify(a)),message:c})),c=c.replace(/\\\^/g,"^"),b.flatten?e.push(c):(e[a]||(e[a]=[])).push(c)})}b=b||{};var d,e=b.flatten?[]:{};if(!a)return e;for(d in a)c(d,a[d]);return e},Promise:f.extend(function(a){var b=f.Promise.nativePromise(a)||f.Promise.RSVPPromise(a)||f.Promise.whenPromise(a)||f.Promise.QPromise(a);if(!b)throw new Error("No promises could be detected");return b},{nativePromise:function(a){var b,c;return"undefined"!=typeof Promise?b=Promise:(c=f.tryRequire("es6-promise"),c&&(b=c.Promise)),b?new b(a):void 0},RSVPPromise:function(a){var b,c;return"undefined"!=typeof RSVP?b=RSVP.Promise:(c=f.tryRequire("rsvp"),c&&(b=c.Promise)),b?new b(a):void 0},whenPromise:function(a){var b,c;return"undefined"!=typeof when?b=when.promise:(c=f.tryRequire("when"),c&&(b=c.promise)),b?b(a):void 0},QPromise:function(a){var b,c;return"undefined"!=typeof Q?b=Q.promise:(c=f.tryRequire("q"),c&&(b=c.promise)),b?b(a):void 0}}),tryRequire:function(a){if(!f.require)return null;try{return f.require(a)}catch(b){return null}},require:d,exposeModule:function(a,b,c,d,e){c?(d&&d.exports&&(c=d.exports=a),c.validate=a):(b.validate=a,a.isFunction(e)&&e.amd&&e("validate",[],function(){return a}))},warn:function(a){"undefined"!=typeof console&&console.warn&&console.warn(a)},error:function(a){"undefined"!=typeof console&&console.error&&console.error(a)}}),e.validators={presence:function(a,b){var c,d=b.message||"can't be blank";if(!f.isDefined(a))return d;if(!f.isFunction(a))if("string"==typeof a){if(/^\s*$/.test(a))return d}else if(f.isArray(a)){if(0===a.length)return d}else if(f.isObject(a)){for(c in a)return;return d}},length:function(a,b){if(f.isDefined(a)){var c,d=b.is,e=b.maximum,g=b.minimum,h=b.tokenizer||function(a){return a},i=[];return a=h(a),f.isNumber(d)&&a.length!==d&&(c=b.wrongLength||"is the wrong length (should be %{count} characters)",i.push(f.format(c,{count:d}))),f.isNumber(g)&&a.length<g&&(c=b.tooShort||"is too short (minimum is %{count} characters)",i.push(f.format(c,{count:g}))),f.isNumber(e)&&a.length>e&&(c=b.tooLong||"is too long (maximum is %{count} characters)",i.push(f.format(c,{count:e}))),i.length>0?b.message||i:void 0}},numericality:function(a,b){if(f.isDefined(a)){var c,d,e=[],g={greaterThan:function(a,b){return a>b},greaterThanOrEqualTo:function(a,b){return a>=b},equalTo:function(a,b){return a===b},lessThan:function(a,b){return b>a},lessThanOrEqualTo:function(a,b){return b>=a}};if(b.noStrings!==!0&&f.isString(a)&&(a=+a),!f.isNumber(a))return b.message||"is not a number";if(b.onlyInteger&&!f.isInteger(a))return b.message||"must be an integer";for(c in g)d=b[c],f.isNumber(d)&&!g[c](a,d)&&e.push(f.format("must be %{type} %{count}",{count:d,type:f.prettify(c)}));return b.odd&&a%2!==1&&e.push("must be odd"),b.even&&a%2!==0&&e.push("must be even"),e.length?b.message||e:void 0}},datetime:f.extend(function(a,b){if(f.isDefined(a)){var c,d=[],e=b.message,g=b.earliest?this.parse(b.earliest,b):0/0,h=b.latest?this.parse(b.latest,b):0/0;return a=this.parse(a,b),isNaN(a)||b.dateOnly&&a%864e5!==0?e||"must be a valid date":(!isNaN(g)&&g>a&&(c="must be no earlier than %{date}",c=f.format(c,{date:this.format(g,b)}),d.push(c)),!isNaN(h)&&a>h&&(c="must be no later than %{date}",c=f.format(c,{date:this.format(h,b)}),d.push(c)),d.length?b.message||d:void 0)}},{parse:function(a){if(f.isFunction(g.XDate))return new g.XDate(a,!0).getTime();var b=f.tryRequire("moment");if(f.isDefined(b))return+b.utc(a);throw new Error("Neither XDate or moment.js was found")},format:function(a,b){var c=b.dateFormat;if(f.isFunction(g.XDate))return c=c||(b.dateOnly?"yyyy-MM-dd":"yyyy-MM-dd HH:mm:ss"),new XDate(a,!0).toString(c);var d=f.tryRequire("moment");if(f.isDefined(d))return c=c||(b.dateOnly?"YYYY-MM-DD":"YYYY-MM-DD HH:mm:ss"),d.utc(a).format(c);throw new Error("Neither XDate or moment.js was found")}}),date:function(a,b){return b=f.extend({},b,{onlyDate:!0}),f.validators.datetime.call(f.validators.datetime,a,b)},format:function(a,b){(f.isString(b)||b instanceof RegExp)&&(b={pattern:b});var c,d=b.message||"is invalid",e=b.pattern;if(f.isDefined(a))return f.isString(a)?(f.isString(e)&&(e=new RegExp(b.pattern,b.flags)),c=e.exec(a),c&&c[0].length==a.length?void 0:d):d},inclusion:function(a,b){if(f.isArray(b)&&(b={within:b}),f.isDefined(a)&&!f.contains(b.within,a)){var c=b.message||"^%{value} is not included in the list";return f.format(c,{value:a})}},exclusion:function(a,b){if(f.isArray(b)&&(b={within:b}),f.isDefined(a)&&f.contains(b.within,a)){var c=b.message||"^%{value} is restricted";return f.format(c,{value:a})}},email:f.extend(function(a,b){var c=b.message||"is not a valid email";if(f.isDefined(a))return f.isString(a)&&this.PATTERN.exec(a)?void 0:c},{PATTERN:/^[a-z0-9\u007F-\uffff!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9\u007F-\uffff!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}$/i})},e.exposeModule(e,g,a,b,c)}).call(this,"undefined"!=typeof exports?exports:null,"undefined"!=typeof module?module:null,"undefined"!=typeof define?define:null,"undefined"!=typeof require?require:null);
//# sourceMappingURL=validate.min.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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