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

backbone-validation

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

backbone-validation - npm Package Compare versions

Comparing version 0.7.1 to 0.8.0

lib/backbone-0.9.10.js

2

buster.js

@@ -8,3 +8,3 @@ var config = exports;

'lib/underscore.js',
'lib/backbone-0.9.9.js',
'lib/backbone-1.0.0.js',
'dist/backbone-validation.js'

@@ -11,0 +11,0 @@ ],

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

// Backbone.Validation v0.7.1
// Backbone.Validation v0.8.0
//
// Copyright (c) 2011-2012 Thomas Pedersen
// Copyright (c) 2011-2013 Thomas Pedersen
// Distributed under MIT License

@@ -8,2 +8,2 @@ //

// http://thedersen.com/projects/backbone-validation
(function(e){typeof exports=="object"?module.exports=e(require("backbone"),require("underscore")):typeof define=="function"&&define.amd&&define(["backbone","underscore"],e)})(function(e,t){return e.Validation=function(e){"use strict";var t={forceUpdate:!1,selector:"name",labelFormatter:"sentenceCase",valid:Function.prototype,invalid:Function.prototype},n={formatLabel:function(e,n){return a[t.labelFormatter](e,n)},format:function(){var e=Array.prototype.slice.call(arguments),t=e.shift();return t.replace(/\{(\d+)\}/g,function(t,n){return typeof e[n]!="undefined"?e[n]:t})}},r=function(t,n,i){return n=n||{},i=i||"",e.each(t,function(e,s){t.hasOwnProperty(s)&&(!e||typeof e!="object"||e instanceof Date||e instanceof RegExp?n[i+s]=e:r(e,n,i+s+"."))}),n},i=function(){var i=function(t){return e.reduce(e.keys(t.validation||{}),function(e,t){return e[t]=void 0,e},{})},o=function(t,n){var r=t.validation?t.validation[n]||{}:{};if(e.isFunction(r)||e.isString(r))r={fn:r};return e.isArray(r)||(r=[r]),e.reduce(r,function(t,n){return e.each(e.without(e.keys(n),"msg"),function(e){t.push({fn:f[e],val:n[e],msg:n.msg})}),t},[])},u=function(t,r,i,s){return e.reduce(o(t,r),function(o,u){var a=e.extend({},n,f),l=u.fn.call(a,i,r,u.val,t,s);return l===!1||o===!1?!1:l&&!o?u.msg||l:o},"")},a=function(t,n){var i,s={},o=!0,a=e.clone(n),f=r(n);return e.each(f,function(e,n){i=u(t,n,e,a),i&&(s[n]=i,o=!1)}),{invalidAttrs:s,isValid:o}},l=function(t,n){return{preValidate:function(t,n){return u(this,t,n,e.extend({},this.attributes))},isValid:function(t){var n=r(this.attributes);return e.isString(t)?!u(this,t,n[t],e.extend({},this.attributes)):e.isArray(t)?e.reduce(t,function(t,r){return t&&!u(this,r,n[r],e.extend({},this.attributes))},!0,this):(t===!0&&this.validate(),this.validation?this._isValid:!0)},validate:function(s,o){var u=this,f=!s,l=e.extend({},n,o),c=i(u),h=e.extend({},c,u.attributes,s),p=r(s||h),d=a(u,h);u._isValid=d.isValid,e.each(c,function(e,n){var r=d.invalidAttrs.hasOwnProperty(n);r||l.valid(t,n,l.selector)}),e.each(c,function(e,n){var r=d.invalidAttrs.hasOwnProperty(n),i=p.hasOwnProperty(n);r&&(i||f)&&l.invalid(t,n,d.invalidAttrs[n],l.selector)}),e.defer(function(){u.trigger("validated",u._isValid,u,d.invalidAttrs),u.trigger("validated:"+(u._isValid?"valid":"invalid"),u,d.invalidAttrs)});if(!l.forceUpdate&&e.intersection(e.keys(d.invalidAttrs),e.keys(p)).length>0)return d.invalidAttrs}}},c=function(t,n,r){e.extend(n,l(t,r))},h=function(e){delete e.validate,delete e.preValidate,delete e.isValid},p=function(e){c(this.view,e,this.options)},d=function(e){h(e)};return{version:"0.7.1",configure:function(n){e.extend(t,n)},bind:function(n,r){var i=n.model,o=n.collection;r=e.extend({},t,s,r);if(typeof i=="undefined"&&typeof o=="undefined")throw"Before you execute the binding your view must have a model or a collection.\nSee http://thedersen.com/projects/backbone-validation/#using-form-model-validation for more information.";i?c(n,i,r):o&&(o.each(function(e){c(n,e,r)}),o.bind("add",p,{view:n,options:r}),o.bind("remove",d))},unbind:function(e){var t=e.model,n=e.collection;t&&h(e.model),n&&(n.each(function(e){h(e)}),n.unbind("add",p),n.unbind("remove",d))},mixin:l(null,t)}}(),s=i.callbacks={valid:function(e,t,n){e.$("["+n+'~="'+t+'"]').removeClass("invalid").removeAttr("data-error")},invalid:function(e,t,n,r){e.$("["+r+'~="'+t+'"]').addClass("invalid").attr("data-error",n)}},o=i.patterns={digits:/^\d+$/,number:/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/,email:/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i,url:/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i},u=i.messages={required:"{0} is required",acceptance:"{0} must be accepted",min:"{0} must be greater than or equal to {1}",max:"{0} must be less than or equal to {1}",range:"{0} must be between {1} and {2}",length:"{0} must be {1} characters",minLength:"{0} must be at least {1} characters",maxLength:"{0} must be at most {1} characters",rangeLength:"{0} must be between {1} and {2} characters",oneOf:"{0} must be one of: {1}",equalTo:"{0} must be the same as {1}",pattern:"{0} must be a valid {1}"},a=i.labelFormatters={none:function(e){return e},sentenceCase:function(e){return e.replace(/(?:^\w|[A-Z]|\b\w)/g,function(e,t){return t===0?e.toUpperCase():" "+e.toLowerCase()}).replace("_"," ")},label:function(e,t){return t.labels&&t.labels[e]||a.sentenceCase(e,t)}},f=i.validators=function(){var t=String.prototype.trim?function(e){return e===null?"":String.prototype.trim.call(e)}:function(e){var t=/^\s+/,n=/\s+$/;return e===null?"":e.toString().replace(t,"").replace(n,"")},n=function(t){return e.isNumber(t)||e.isString(t)&&t.match(o.number)},r=function(n){return!(e.isNull(n)||e.isUndefined(n)||e.isString(n)&&t(n)==="")};return{fn:function(t,n,r,i,s){return e.isString(r)&&(r=i[r]),r.call(i,t,n,s)},required:function(t,n,i,s,o){var a=e.isFunction(i)?i.call(s,t,n,o):i;if(!a&&!r(t))return!1;if(a&&!r(t))return this.format(u.required,this.formatLabel(n,s))},acceptance:function(t,n,r,i){if(t!=="true"&&(!e.isBoolean(t)||t===!1))return this.format(u.acceptance,this.formatLabel(n,i))},min:function(e,t,r,i){if(!n(e)||e<r)return this.format(u.min,this.formatLabel(t,i),r)},max:function(e,t,r,i){if(!n(e)||e>r)return this.format(u.max,this.formatLabel(t,i),r)},range:function(e,t,r,i){if(!n(e)||e<r[0]||e>r[1])return this.format(u.range,this.formatLabel(t,i),r[0],r[1])},length:function(e,n,i,s){if(!r(e)||t(e).length!==i)return this.format(u.length,this.formatLabel(n,s),i)},minLength:function(e,n,i,s){if(!r(e)||t(e).length<i)return this.format(u.minLength,this.formatLabel(n,s),i)},maxLength:function(e,n,i,s){if(!r(e)||t(e).length>i)return this.format(u.maxLength,this.formatLabel(n,s),i)},rangeLength:function(e,n,i,s){if(!r(e)||t(e).length<i[0]||t(e).length>i[1])return this.format(u.rangeLength,this.formatLabel(n,s),i[0],i[1])},oneOf:function(t,n,r,i){if(!e.include(r,t))return this.format(u.oneOf,this.formatLabel(n,i),r.join(", "))},equalTo:function(e,t,n,r,i){if(e!==i[n])return this.format(u.equalTo,this.formatLabel(t,r),this.formatLabel(n,r))},pattern:function(e,t,n,i){if(!r(e)||!e.toString().match(o[n]||n))return this.format(u.pattern,this.formatLabel(t,i),n)}}}();return i}(t),e.Validation});
(function(e){typeof exports=="object"?module.exports=e(require("backbone"),require("underscore")):typeof define=="function"&&define.amd&&define(["backbone","underscore"],e)})(function(e,t){return e.Validation=function(t){"use strict";var n={forceUpdate:!1,selector:"name",labelFormatter:"sentenceCase",valid:Function.prototype,invalid:Function.prototype},r={formatLabel:function(e,t){return f[n.labelFormatter](e,t)},format:function(){var e=Array.prototype.slice.call(arguments),t=e.shift();return t.replace(/\{(\d+)\}/g,function(t,n){return typeof e[n]!="undefined"?e[n]:t})}},i=function(n,r,s){return r=r||{},s=s||"",t.each(n,function(t,o){n.hasOwnProperty(o)&&(!t||typeof t!="object"||t instanceof Date||t instanceof RegExp||t instanceof e.Model||t instanceof e.Collection?r[s+o]=t:i(t,r,s+o+"."))}),r},s=function(){var e=function(e){return t.reduce(t.keys(e.validation||{}),function(e,t){return e[t]=void 0,e},{})},s=function(e,n){var r=e.validation?e.validation[n]||{}:{};if(t.isFunction(r)||t.isString(r))r={fn:r};return t.isArray(r)||(r=[r]),t.reduce(r,function(e,n){return t.each(t.without(t.keys(n),"msg"),function(t){e.push({fn:l[t],val:n[t],msg:n.msg})}),e},[])},u=function(e,n,i,o){return t.reduce(s(e,n),function(s,u){var a=t.extend({},r,l),f=u.fn.call(a,i,n,u.val,e,o);return f===!1||s===!1?!1:f&&!s?u.msg||f:s},"")},a=function(e,n){var r,s={},o=!0,a=t.clone(n),f=i(n);return t.each(f,function(t,n){r=u(e,n,t,a),r&&(s[n]=r,o=!1)}),{invalidAttrs:s,isValid:o}},f=function(n,r){return{preValidate:function(e,n){return u(this,e,n,t.extend({},this.attributes))},isValid:function(e){var n=i(this.attributes);return t.isString(e)?!u(this,e,n[e],t.extend({},this.attributes)):t.isArray(e)?t.reduce(e,function(e,r){return e&&!u(this,r,n[r],t.extend({},this.attributes))},!0,this):(e===!0&&this.validate(),this.validation?this._isValid:!0)},validate:function(s,o){var u=this,f=!s,l=t.extend({},r,o),c=e(u),h=t.extend({},c,u.attributes,s),p=i(s||h),d=a(u,h);u._isValid=d.isValid,t.each(c,function(e,t){var r=d.invalidAttrs.hasOwnProperty(t);r||l.valid(n,t,l.selector)}),t.each(c,function(e,t){var r=d.invalidAttrs.hasOwnProperty(t),i=p.hasOwnProperty(t);r&&(i||f)&&l.invalid(n,t,d.invalidAttrs[t],l.selector)}),t.defer(function(){u.trigger("validated",u._isValid,u,d.invalidAttrs),u.trigger("validated:"+(u._isValid?"valid":"invalid"),u,d.invalidAttrs)});if(!l.forceUpdate&&t.intersection(t.keys(d.invalidAttrs),t.keys(p)).length>0)return d.invalidAttrs}}},c=function(e,n,r){t.extend(n,f(e,r))},h=function(e){delete e.validate,delete e.preValidate,delete e.isValid},p=function(e){c(this.view,e,this.options)},d=function(e){h(e)};return{version:"0.8.0",configure:function(e){t.extend(n,e)},bind:function(e,r){var i=e.model,s=e.collection;r=t.extend({},n,o,r);if(typeof i=="undefined"&&typeof s=="undefined")throw"Before you execute the binding your view must have a model or a collection.\nSee http://thedersen.com/projects/backbone-validation/#using-form-model-validation for more information.";i?c(e,i,r):s&&(s.each(function(t){c(e,t,r)}),s.bind("add",p,{view:e,options:r}),s.bind("remove",d))},unbind:function(e){var t=e.model,n=e.collection;t&&h(e.model),n&&(n.each(function(e){h(e)}),n.unbind("add",p),n.unbind("remove",d))},mixin:f(null,n)}}(),o=s.callbacks={valid:function(e,t,n){e.$("["+n+'~="'+t+'"]').removeClass("invalid").removeAttr("data-error")},invalid:function(e,t,n,r){e.$("["+r+'~="'+t+'"]').addClass("invalid").attr("data-error",n)}},u=s.patterns={digits:/^\d+$/,number:/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/,email:/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i,url:/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i},a=s.messages={required:"{0} is required",acceptance:"{0} must be accepted",min:"{0} must be greater than or equal to {1}",max:"{0} must be less than or equal to {1}",range:"{0} must be between {1} and {2}",length:"{0} must be {1} characters",minLength:"{0} must be at least {1} characters",maxLength:"{0} must be at most {1} characters",rangeLength:"{0} must be between {1} and {2} characters",oneOf:"{0} must be one of: {1}",equalTo:"{0} must be the same as {1}",pattern:"{0} must be a valid {1}"},f=s.labelFormatters={none:function(e){return e},sentenceCase:function(e){return e.replace(/(?:^\w|[A-Z]|\b\w)/g,function(e,t){return t===0?e.toUpperCase():" "+e.toLowerCase()}).replace("_"," ")},label:function(e,t){return t.labels&&t.labels[e]||f.sentenceCase(e,t)}},l=s.validators=function(){var e=String.prototype.trim?function(e){return e===null?"":String.prototype.trim.call(e)}:function(e){var t=/^\s+/,n=/\s+$/;return e===null?"":e.toString().replace(t,"").replace(n,"")},n=function(e){return t.isNumber(e)||t.isString(e)&&e.match(u.number)},r=function(n){return!(t.isNull(n)||t.isUndefined(n)||t.isString(n)&&e(n)==="")};return{fn:function(e,n,r,i,s){return t.isString(r)&&(r=i[r]),r.call(i,e,n,s)},required:function(e,n,i,s,o){var u=t.isFunction(i)?i.call(s,e,n,o):i;if(!u&&!r(e))return!1;if(u&&!r(e))return this.format(a.required,this.formatLabel(n,s))},acceptance:function(e,n,r,i){if(e!=="true"&&(!t.isBoolean(e)||e===!1))return this.format(a.acceptance,this.formatLabel(n,i))},min:function(e,t,r,i){if(!n(e)||e<r)return this.format(a.min,this.formatLabel(t,i),r)},max:function(e,t,r,i){if(!n(e)||e>r)return this.format(a.max,this.formatLabel(t,i),r)},range:function(e,t,r,i){if(!n(e)||e<r[0]||e>r[1])return this.format(a.range,this.formatLabel(t,i),r[0],r[1])},length:function(t,n,i,s){if(!r(t)||e(t).length!==i)return this.format(a.length,this.formatLabel(n,s),i)},minLength:function(t,n,i,s){if(!r(t)||e(t).length<i)return this.format(a.minLength,this.formatLabel(n,s),i)},maxLength:function(t,n,i,s){if(!r(t)||e(t).length>i)return this.format(a.maxLength,this.formatLabel(n,s),i)},rangeLength:function(t,n,i,s){if(!r(t)||e(t).length<i[0]||e(t).length>i[1])return this.format(a.rangeLength,this.formatLabel(n,s),i[0],i[1])},oneOf:function(e,n,r,i){if(!t.include(r,e))return this.format(a.oneOf,this.formatLabel(n,i),r.join(", "))},equalTo:function(e,t,n,r,i){if(e!==i[n])return this.format(a.equalTo,this.formatLabel(t,r),this.formatLabel(n,r))},pattern:function(e,t,n,i){if(!r(e)||!e.toString().match(u[n]||n))return this.format(a.pattern,this.formatLabel(t,i),n)}}}();return s}(t),e.Validation});

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

// Backbone.Validation v0.7.1
// Backbone.Validation v0.8.0
//
// Copyright (c) 2011-2012 Thomas Pedersen
// Copyright (c) 2011-2013 Thomas Pedersen
// Distributed under MIT License

@@ -74,3 +74,8 @@ //

if(obj.hasOwnProperty(key)) {
if (val && typeof val === 'object' && !(val instanceof Date || val instanceof RegExp)) {
if (val && typeof val === 'object' && !(
val instanceof Date ||
val instanceof RegExp ||
val instanceof Backbone.Model ||
val instanceof Backbone.Collection)
) {
flatten(val, into, prefix + key + '.');

@@ -294,3 +299,3 @@ }

// Current version of the library
version: '0.7.1',
version: '0.8.0',

@@ -297,0 +302,0 @@ // Called to configure the default options

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

// Backbone.Validation v0.7.1
// Backbone.Validation v0.8.0
//
// Copyright (c) 2011-2012 Thomas Pedersen
// Copyright (c) 2011-2013 Thomas Pedersen
// Distributed under MIT License

@@ -8,2 +8,2 @@ //

// http://thedersen.com/projects/backbone-validation
Backbone.Validation=function(e){"use strict";var t={forceUpdate:!1,selector:"name",labelFormatter:"sentenceCase",valid:Function.prototype,invalid:Function.prototype},n={formatLabel:function(e,n){return a[t.labelFormatter](e,n)},format:function(){var e=Array.prototype.slice.call(arguments),t=e.shift();return t.replace(/\{(\d+)\}/g,function(t,n){return typeof e[n]!="undefined"?e[n]:t})}},r=function(t,n,i){return n=n||{},i=i||"",e.each(t,function(e,s){t.hasOwnProperty(s)&&(!e||typeof e!="object"||e instanceof Date||e instanceof RegExp?n[i+s]=e:r(e,n,i+s+"."))}),n},i=function(){var i=function(t){return e.reduce(e.keys(t.validation||{}),function(e,t){return e[t]=void 0,e},{})},o=function(t,n){var r=t.validation?t.validation[n]||{}:{};if(e.isFunction(r)||e.isString(r))r={fn:r};return e.isArray(r)||(r=[r]),e.reduce(r,function(t,n){return e.each(e.without(e.keys(n),"msg"),function(e){t.push({fn:f[e],val:n[e],msg:n.msg})}),t},[])},u=function(t,r,i,s){return e.reduce(o(t,r),function(o,u){var a=e.extend({},n,f),l=u.fn.call(a,i,r,u.val,t,s);return l===!1||o===!1?!1:l&&!o?u.msg||l:o},"")},a=function(t,n){var i,s={},o=!0,a=e.clone(n),f=r(n);return e.each(f,function(e,n){i=u(t,n,e,a),i&&(s[n]=i,o=!1)}),{invalidAttrs:s,isValid:o}},l=function(t,n){return{preValidate:function(t,n){return u(this,t,n,e.extend({},this.attributes))},isValid:function(t){var n=r(this.attributes);return e.isString(t)?!u(this,t,n[t],e.extend({},this.attributes)):e.isArray(t)?e.reduce(t,function(t,r){return t&&!u(this,r,n[r],e.extend({},this.attributes))},!0,this):(t===!0&&this.validate(),this.validation?this._isValid:!0)},validate:function(s,o){var u=this,f=!s,l=e.extend({},n,o),c=i(u),h=e.extend({},c,u.attributes,s),p=r(s||h),d=a(u,h);u._isValid=d.isValid,e.each(c,function(e,n){var r=d.invalidAttrs.hasOwnProperty(n);r||l.valid(t,n,l.selector)}),e.each(c,function(e,n){var r=d.invalidAttrs.hasOwnProperty(n),i=p.hasOwnProperty(n);r&&(i||f)&&l.invalid(t,n,d.invalidAttrs[n],l.selector)}),e.defer(function(){u.trigger("validated",u._isValid,u,d.invalidAttrs),u.trigger("validated:"+(u._isValid?"valid":"invalid"),u,d.invalidAttrs)});if(!l.forceUpdate&&e.intersection(e.keys(d.invalidAttrs),e.keys(p)).length>0)return d.invalidAttrs}}},c=function(t,n,r){e.extend(n,l(t,r))},h=function(e){delete e.validate,delete e.preValidate,delete e.isValid},p=function(e){c(this.view,e,this.options)},d=function(e){h(e)};return{version:"0.7.1",configure:function(n){e.extend(t,n)},bind:function(n,r){var i=n.model,o=n.collection;r=e.extend({},t,s,r);if(typeof i=="undefined"&&typeof o=="undefined")throw"Before you execute the binding your view must have a model or a collection.\nSee http://thedersen.com/projects/backbone-validation/#using-form-model-validation for more information.";i?c(n,i,r):o&&(o.each(function(e){c(n,e,r)}),o.bind("add",p,{view:n,options:r}),o.bind("remove",d))},unbind:function(e){var t=e.model,n=e.collection;t&&h(e.model),n&&(n.each(function(e){h(e)}),n.unbind("add",p),n.unbind("remove",d))},mixin:l(null,t)}}(),s=i.callbacks={valid:function(e,t,n){e.$("["+n+'~="'+t+'"]').removeClass("invalid").removeAttr("data-error")},invalid:function(e,t,n,r){e.$("["+r+'~="'+t+'"]').addClass("invalid").attr("data-error",n)}},o=i.patterns={digits:/^\d+$/,number:/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/,email:/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i,url:/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i},u=i.messages={required:"{0} is required",acceptance:"{0} must be accepted",min:"{0} must be greater than or equal to {1}",max:"{0} must be less than or equal to {1}",range:"{0} must be between {1} and {2}",length:"{0} must be {1} characters",minLength:"{0} must be at least {1} characters",maxLength:"{0} must be at most {1} characters",rangeLength:"{0} must be between {1} and {2} characters",oneOf:"{0} must be one of: {1}",equalTo:"{0} must be the same as {1}",pattern:"{0} must be a valid {1}"},a=i.labelFormatters={none:function(e){return e},sentenceCase:function(e){return e.replace(/(?:^\w|[A-Z]|\b\w)/g,function(e,t){return t===0?e.toUpperCase():" "+e.toLowerCase()}).replace("_"," ")},label:function(e,t){return t.labels&&t.labels[e]||a.sentenceCase(e,t)}},f=i.validators=function(){var t=String.prototype.trim?function(e){return e===null?"":String.prototype.trim.call(e)}:function(e){var t=/^\s+/,n=/\s+$/;return e===null?"":e.toString().replace(t,"").replace(n,"")},n=function(t){return e.isNumber(t)||e.isString(t)&&t.match(o.number)},r=function(n){return!(e.isNull(n)||e.isUndefined(n)||e.isString(n)&&t(n)==="")};return{fn:function(t,n,r,i,s){return e.isString(r)&&(r=i[r]),r.call(i,t,n,s)},required:function(t,n,i,s,o){var a=e.isFunction(i)?i.call(s,t,n,o):i;if(!a&&!r(t))return!1;if(a&&!r(t))return this.format(u.required,this.formatLabel(n,s))},acceptance:function(t,n,r,i){if(t!=="true"&&(!e.isBoolean(t)||t===!1))return this.format(u.acceptance,this.formatLabel(n,i))},min:function(e,t,r,i){if(!n(e)||e<r)return this.format(u.min,this.formatLabel(t,i),r)},max:function(e,t,r,i){if(!n(e)||e>r)return this.format(u.max,this.formatLabel(t,i),r)},range:function(e,t,r,i){if(!n(e)||e<r[0]||e>r[1])return this.format(u.range,this.formatLabel(t,i),r[0],r[1])},length:function(e,n,i,s){if(!r(e)||t(e).length!==i)return this.format(u.length,this.formatLabel(n,s),i)},minLength:function(e,n,i,s){if(!r(e)||t(e).length<i)return this.format(u.minLength,this.formatLabel(n,s),i)},maxLength:function(e,n,i,s){if(!r(e)||t(e).length>i)return this.format(u.maxLength,this.formatLabel(n,s),i)},rangeLength:function(e,n,i,s){if(!r(e)||t(e).length<i[0]||t(e).length>i[1])return this.format(u.rangeLength,this.formatLabel(n,s),i[0],i[1])},oneOf:function(t,n,r,i){if(!e.include(r,t))return this.format(u.oneOf,this.formatLabel(n,i),r.join(", "))},equalTo:function(e,t,n,r,i){if(e!==i[n])return this.format(u.equalTo,this.formatLabel(t,r),this.formatLabel(n,r))},pattern:function(e,t,n,i){if(!r(e)||!e.toString().match(o[n]||n))return this.format(u.pattern,this.formatLabel(t,i),n)}}}();return i}(_);
Backbone.Validation=function(e){"use strict";var t={forceUpdate:!1,selector:"name",labelFormatter:"sentenceCase",valid:Function.prototype,invalid:Function.prototype},n={formatLabel:function(e,n){return a[t.labelFormatter](e,n)},format:function(){var e=Array.prototype.slice.call(arguments),t=e.shift();return t.replace(/\{(\d+)\}/g,function(t,n){return typeof e[n]!="undefined"?e[n]:t})}},r=function(t,n,i){return n=n||{},i=i||"",e.each(t,function(e,s){t.hasOwnProperty(s)&&(!e||typeof e!="object"||e instanceof Date||e instanceof RegExp||e instanceof Backbone.Model||e instanceof Backbone.Collection?n[i+s]=e:r(e,n,i+s+"."))}),n},i=function(){var i=function(t){return e.reduce(e.keys(t.validation||{}),function(e,t){return e[t]=void 0,e},{})},o=function(t,n){var r=t.validation?t.validation[n]||{}:{};if(e.isFunction(r)||e.isString(r))r={fn:r};return e.isArray(r)||(r=[r]),e.reduce(r,function(t,n){return e.each(e.without(e.keys(n),"msg"),function(e){t.push({fn:f[e],val:n[e],msg:n.msg})}),t},[])},u=function(t,r,i,s){return e.reduce(o(t,r),function(o,u){var a=e.extend({},n,f),l=u.fn.call(a,i,r,u.val,t,s);return l===!1||o===!1?!1:l&&!o?u.msg||l:o},"")},a=function(t,n){var i,s={},o=!0,a=e.clone(n),f=r(n);return e.each(f,function(e,n){i=u(t,n,e,a),i&&(s[n]=i,o=!1)}),{invalidAttrs:s,isValid:o}},l=function(t,n){return{preValidate:function(t,n){return u(this,t,n,e.extend({},this.attributes))},isValid:function(t){var n=r(this.attributes);return e.isString(t)?!u(this,t,n[t],e.extend({},this.attributes)):e.isArray(t)?e.reduce(t,function(t,r){return t&&!u(this,r,n[r],e.extend({},this.attributes))},!0,this):(t===!0&&this.validate(),this.validation?this._isValid:!0)},validate:function(s,o){var u=this,f=!s,l=e.extend({},n,o),c=i(u),h=e.extend({},c,u.attributes,s),p=r(s||h),d=a(u,h);u._isValid=d.isValid,e.each(c,function(e,n){var r=d.invalidAttrs.hasOwnProperty(n);r||l.valid(t,n,l.selector)}),e.each(c,function(e,n){var r=d.invalidAttrs.hasOwnProperty(n),i=p.hasOwnProperty(n);r&&(i||f)&&l.invalid(t,n,d.invalidAttrs[n],l.selector)}),e.defer(function(){u.trigger("validated",u._isValid,u,d.invalidAttrs),u.trigger("validated:"+(u._isValid?"valid":"invalid"),u,d.invalidAttrs)});if(!l.forceUpdate&&e.intersection(e.keys(d.invalidAttrs),e.keys(p)).length>0)return d.invalidAttrs}}},c=function(t,n,r){e.extend(n,l(t,r))},h=function(e){delete e.validate,delete e.preValidate,delete e.isValid},p=function(e){c(this.view,e,this.options)},d=function(e){h(e)};return{version:"0.8.0",configure:function(n){e.extend(t,n)},bind:function(n,r){var i=n.model,o=n.collection;r=e.extend({},t,s,r);if(typeof i=="undefined"&&typeof o=="undefined")throw"Before you execute the binding your view must have a model or a collection.\nSee http://thedersen.com/projects/backbone-validation/#using-form-model-validation for more information.";i?c(n,i,r):o&&(o.each(function(e){c(n,e,r)}),o.bind("add",p,{view:n,options:r}),o.bind("remove",d))},unbind:function(e){var t=e.model,n=e.collection;t&&h(e.model),n&&(n.each(function(e){h(e)}),n.unbind("add",p),n.unbind("remove",d))},mixin:l(null,t)}}(),s=i.callbacks={valid:function(e,t,n){e.$("["+n+'~="'+t+'"]').removeClass("invalid").removeAttr("data-error")},invalid:function(e,t,n,r){e.$("["+r+'~="'+t+'"]').addClass("invalid").attr("data-error",n)}},o=i.patterns={digits:/^\d+$/,number:/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/,email:/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i,url:/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i},u=i.messages={required:"{0} is required",acceptance:"{0} must be accepted",min:"{0} must be greater than or equal to {1}",max:"{0} must be less than or equal to {1}",range:"{0} must be between {1} and {2}",length:"{0} must be {1} characters",minLength:"{0} must be at least {1} characters",maxLength:"{0} must be at most {1} characters",rangeLength:"{0} must be between {1} and {2} characters",oneOf:"{0} must be one of: {1}",equalTo:"{0} must be the same as {1}",pattern:"{0} must be a valid {1}"},a=i.labelFormatters={none:function(e){return e},sentenceCase:function(e){return e.replace(/(?:^\w|[A-Z]|\b\w)/g,function(e,t){return t===0?e.toUpperCase():" "+e.toLowerCase()}).replace("_"," ")},label:function(e,t){return t.labels&&t.labels[e]||a.sentenceCase(e,t)}},f=i.validators=function(){var t=String.prototype.trim?function(e){return e===null?"":String.prototype.trim.call(e)}:function(e){var t=/^\s+/,n=/\s+$/;return e===null?"":e.toString().replace(t,"").replace(n,"")},n=function(t){return e.isNumber(t)||e.isString(t)&&t.match(o.number)},r=function(n){return!(e.isNull(n)||e.isUndefined(n)||e.isString(n)&&t(n)==="")};return{fn:function(t,n,r,i,s){return e.isString(r)&&(r=i[r]),r.call(i,t,n,s)},required:function(t,n,i,s,o){var a=e.isFunction(i)?i.call(s,t,n,o):i;if(!a&&!r(t))return!1;if(a&&!r(t))return this.format(u.required,this.formatLabel(n,s))},acceptance:function(t,n,r,i){if(t!=="true"&&(!e.isBoolean(t)||t===!1))return this.format(u.acceptance,this.formatLabel(n,i))},min:function(e,t,r,i){if(!n(e)||e<r)return this.format(u.min,this.formatLabel(t,i),r)},max:function(e,t,r,i){if(!n(e)||e>r)return this.format(u.max,this.formatLabel(t,i),r)},range:function(e,t,r,i){if(!n(e)||e<r[0]||e>r[1])return this.format(u.range,this.formatLabel(t,i),r[0],r[1])},length:function(e,n,i,s){if(!r(e)||t(e).length!==i)return this.format(u.length,this.formatLabel(n,s),i)},minLength:function(e,n,i,s){if(!r(e)||t(e).length<i)return this.format(u.minLength,this.formatLabel(n,s),i)},maxLength:function(e,n,i,s){if(!r(e)||t(e).length>i)return this.format(u.maxLength,this.formatLabel(n,s),i)},rangeLength:function(e,n,i,s){if(!r(e)||t(e).length<i[0]||t(e).length>i[1])return this.format(u.rangeLength,this.formatLabel(n,s),i[0],i[1])},oneOf:function(t,n,r,i){if(!e.include(r,t))return this.format(u.oneOf,this.formatLabel(n,i),r.join(", "))},equalTo:function(e,t,n,r,i){if(e!==i[n])return this.format(u.equalTo,this.formatLabel(t,r),this.formatLabel(n,r))},pattern:function(e,t,n,i){if(!r(e)||!e.toString().match(o[n]||n))return this.format(u.pattern,this.formatLabel(t,i),n)}}}();return i}(_);

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

// Backbone.Validation v0.7.1
// Backbone.Validation v0.8.0
//
// Copyright (c) 2011-2012 Thomas Pedersen
// Copyright (c) 2011-2013 Thomas Pedersen
// Distributed under MIT License

@@ -67,3 +67,8 @@ //

if(obj.hasOwnProperty(key)) {
if (val && typeof val === 'object' && !(val instanceof Date || val instanceof RegExp)) {
if (val && typeof val === 'object' && !(
val instanceof Date ||
val instanceof RegExp ||
val instanceof Backbone.Model ||
val instanceof Backbone.Collection)
) {
flatten(val, into, prefix + key + '.');

@@ -287,3 +292,3 @@ }

// Current version of the library
version: '0.7.1',
version: '0.8.0',

@@ -290,0 +295,0 @@ // Called to configure the default options

_.extend(Backbone.Validation.callbacks, {
valid: function(view, attr, selector){
selector = (selector == 'id'
? '#' + attr
: '[' + selector + '=' + attr + ']');
var control = view.$('[' + selector + '=' + attr + ']');

@@ -21,2 +24,5 @@ var group = control.parents(".control-group");

invalid: function(view, attr, error, selector) {
selector = (selector == 'id'
? '#' + attr
: '[' + selector + '=' + attr + ']');
var control = view.$('[' + selector + '=' + attr + ']');

@@ -50,2 +56,2 @@ var group = control.parents(".control-group");

}
});
});

@@ -96,3 +96,3 @@

clone: {
command: 'git clone git@github.com:thedersen/thedersen.github.com.git',
command: 'git clone https://github.com/thedersen/thedersen.github.com.git',
stdout: true,

@@ -99,0 +99,0 @@ stderr: true

{
"name": "backbone-validation",
"title": "Backbone.Validation",
"version": "0.7.1",
"version": "0.8.0",
"author": {

@@ -6,0 +6,0 @@ "name": "Thomas Pedersen",

@@ -1,2 +0,2 @@

# Backbone.Validation v0.7.1
# Backbone.Validation v0.8.0

@@ -21,3 +21,3 @@ A validation plugin for [Backbone.js](http://documentcloud.github.com/backbone) that validates both your model as well as form input.

* Development: [backbone-validation.js](https://raw.github.com/thedersen/backbone.validation/master/dist/backbone-validation.js) *22.6kb*
* Development: [backbone-validation.js](https://raw.github.com/thedersen/backbone.validation/master/dist/backbone-validation.js) *22.7kb*
* Production: [backbone-validation-min.js](https://raw.github.com/thedersen/backbone.validation/master/dist/backbone-validation-min.js) *2.7kb gzipped*

@@ -27,3 +27,3 @@

* Development: [backbone-validation-amd.js](https://raw.github.com/thedersen/backbone.validation/master/dist/backbone-validation-amd.js) *24.1kb*
* Development: [backbone-validation-amd.js](https://raw.github.com/thedersen/backbone.validation/master/dist/backbone-validation-amd.js) *24.2kb*
* Production: [backbone-validation-amd-min.js](https://raw.github.com/thedersen/backbone.validation/master/dist/backbone-validation-amd-min.js) *2.8kb gzipped*

@@ -41,5 +41,3 @@

* 0.9.1
* 0.9.2
* 0.9.9
* 1.0

@@ -121,3 +119,3 @@ ### Configure validation rules on the Model

Note that Backbone.Validation does not provide any automatic/two-way binding between your model and the view, that's up you to implement (you can for instance use [Backbone.stickit](http://nytimes.github.com/backbone.stickit/).
Note that Backbone.Validation does not provide any automatic/two-way binding between your model and the view, that's up you to implement (you can for instance use [Backbone.stickit](http://nytimes.github.com/backbone.stickit/)).

@@ -783,2 +781,8 @@ Before you can start using form validation, you need to bind your view.

#### v0.8.0 [commits](https://github.com/thedersen/backbone.validation/compare/v0.7.1...v0.8.0)
* All tests pass Backbone v1.0
* Fixes recursive loop if model attributes contain nested models. Fixes #97 (Thanks to [Adam George](https://github.com/asgeo1))
* Handling id selectors better. Fixes #127 (Thanks to [BigBlueHat](https://github.com/BigBlueHat))
#### v0.7.1 [commits](https://github.com/thedersen/backbone.validation/compare/v0.7.0...v0.7.1)

@@ -924,2 +928,2 @@

http://thedersen.mit-license.org/
http://thedersen.mit-license.org/

@@ -60,3 +60,8 @@ Backbone.Validation = (function(_){

if(obj.hasOwnProperty(key)) {
if (val && typeof val === 'object' && !(val instanceof Date || val instanceof RegExp)) {
if (val && typeof val === 'object' && !(
val instanceof Date ||
val instanceof RegExp ||
val instanceof Backbone.Model ||
val instanceof Backbone.Collection)
) {
flatten(val, into, prefix + key + '.');

@@ -280,3 +285,3 @@ }

// Current version of the library
version: '0.7.1',
version: '0.8.0',

@@ -283,0 +288,0 @@ // Called to configure the default options

@@ -38,3 +38,3 @@ buster.testCase("Overriding default callbacks in Backbone.Validation", {

age: 1
});
}, {validate: true});

@@ -47,3 +47,3 @@ assert.called(this.valid);

age: 0
});
}, {validate: true});

@@ -50,0 +50,0 @@ assert.called(this.invalid);

@@ -24,6 +24,6 @@ buster.testCase('Extending Backbone.Validation with custom pattern', {

name: 'test'
}));
}, {validate: true}));
refute(this.model.set({
name: 'aa'
}));
}, {validate: true}));
}

@@ -61,7 +61,7 @@ });

name: 'test'
}));
}, { validate: true }));
refute(this.model.set({
name: 'aa'
}));
}, { validate: true }));
}
});

@@ -35,3 +35,3 @@ buster.testCase("Overriding default id selector with class", {

this.model.set({name:''});
this.model.set({name:''}, {validate: true});

@@ -49,3 +49,3 @@ assert(this.name.hasClass('invalid'));

});
this.model.set({name:''});
this.model.set({name:''}, {validate: true});

@@ -52,0 +52,0 @@ assert(this.name.hasClass('invalid'));

@@ -30,6 +30,6 @@ buster.testCase('Extending Backbone.Validation with custom validator', {

age: 1
}));
}, {validate: true}));
refute(this.model.set({
age: 2
}));
}, {validate: true}));
}

@@ -71,6 +71,6 @@ });

age: 1
}));
}, {validate: true}));
refute(this.model.set({
age: 2
}));
}, {validate: true}));
}

@@ -77,0 +77,0 @@ });

@@ -26,3 +26,3 @@ buster.testCase("Specifying error messages", {

"and violating first validator returns msg specified for first validator": function() {
this.model.set({email: ''});
this.model.set({email: ''}, {validate: true});

@@ -33,3 +33,3 @@ assert.calledWith(this.invalid, this.view, 'email', 'required');

"and violating second validator returns msg specified for second validator": function() {
this.model.set({email: 'a'});
this.model.set({email: 'a'}, {validate: true});

@@ -52,3 +52,3 @@ assert.calledWith(this.invalid, this.view, 'email', 'pattern');

"and violating first validator returns msg specified for attribute": function() {
this.model.set({email: ''});
this.model.set({email: ''}, {validate: true});

@@ -59,3 +59,3 @@ assert.calledWith(this.invalid, this.view, 'email', 'error');

"and violating second validator returns msg specified for attribute": function() {
this.model.set({email: 'a'});
this.model.set({email: 'a'}, {validate: true});

@@ -62,0 +62,0 @@ assert.calledWith(this.invalid, this.view, 'email', 'error');

@@ -42,3 +42,3 @@ buster.testCase("Backbone.Validation events", {

name: 'name'
});
}, {validate: true});
},

@@ -57,3 +57,3 @@

name: 'name'
});
}, {validate: true});
},

@@ -70,3 +70,3 @@

name: 'name'
});
}, {validate: true});
}

@@ -84,3 +84,3 @@ },

this.model.set({age:0});
this.model.set({age:0}, {validate: true});
},

@@ -95,13 +95,3 @@

this.model.set({age:0});
},
"error event is triggered with model and error as an array of attribute names with error": function(done) {
this.model.bind('error', function(model, error) {
assert.same(this.model, model);
assert.equals({age: 'age', name: 'name'}, error);
done();
}, this);
this.model.set({age:0});
this.model.set({age:0}, {validate: true});
}

@@ -121,3 +111,3 @@ },

age: 1
});
}, {validate: true});
},

@@ -134,5 +124,5 @@

age: 1
}, this);
}, {validate: true});
}
}
});

@@ -20,3 +20,3 @@ buster.testCase("forceUpdate", {

"invalid values are not set on model": function() {
refute(this.model.set({name:''}));
refute(this.model.set({name:''}, {validate: true}));
}

@@ -33,3 +33,3 @@ },

"invalid values are set on model": function() {
assert(this.model.set({name:''}));
assert(this.model.set({name:''}, {validate: true}));
}

@@ -44,3 +44,3 @@ },

"invalid values are set on model": function() {
assert(this.model.set({name:''}, {forceUpdate: true}));
assert(this.model.set({name:''}, {forceUpdate: true, validate: true}));
}

@@ -64,5 +64,5 @@ },

"invalid values are set on model": function() {
assert(this.model.set({name:''}));
assert(this.model.set({name:''}, {validate: true}));
}
}
});

@@ -66,3 +66,3 @@ buster.testCase("Backbone.Validation", {

age: 1
});
}, {validate: true});

@@ -75,3 +75,3 @@ assert.called(this.valid);

age: 0
});
}, {validate: true});

@@ -132,3 +132,3 @@ assert.called(this.invalid);

someProperty: true
}));
}, {validate: true}));
},

@@ -142,3 +142,3 @@

age: 1
});
}, {validate: true});
},

@@ -157,3 +157,3 @@

age: 1
}), this.model);
}, {validate: true}), this.model);
},

@@ -174,3 +174,3 @@

age: 0
});
}, {validate: true});
},

@@ -189,3 +189,3 @@

age: 0
}));
}, {validate: true}));
},

@@ -207,3 +207,3 @@

name: 'hello'
});
}, {validate: true});
},

@@ -226,3 +226,3 @@

name: ''
});
}, {validate: true});
},

@@ -246,3 +246,3 @@

name: ''
});
}, {validate: true});
},

@@ -272,3 +272,3 @@

name: 'name'
});
}, {validate: true});
},

@@ -298,3 +298,3 @@

age: 0
});
}, {validate: true});
refute(this.model.isValid());

@@ -304,3 +304,3 @@

age: 1
});
}, {validate: true});
refute(this.model.isValid());

@@ -310,3 +310,3 @@

name: 'hello'
});
}, {validate: true});
assert(this.model.isValid());

@@ -316,3 +316,3 @@

age: 0
});
}, {validate: true});
refute(this.model.isValid());

@@ -349,4 +349,4 @@ }

"all attributes on the model is validated when one property has been set silently": function(){
this.model.set({age: 1}, {silent:true});
"all attributes on the model is validated when one property has been set without validating": function(){
this.model.set({age: 1});

@@ -359,4 +359,4 @@ this.model.validate();

"all attributes on the model is validated when two properties has been set silently": function(){
this.model.set({age: 1, name: 'name'}, {silent:true});
"all attributes on the model is validated when two properties has been set without validating": function(){
this.model.set({age: 1, name: 'name'});

@@ -371,3 +371,3 @@ this.model.validate();

this.model.set({age: 1, name: 'name', someProp: 'some value'}, {silent:true});
this.model.set({age: 1, name: 'name', someProp: 'some value'});

@@ -402,3 +402,3 @@ this.model.validate();

"and violating the first validator the model is invalid": function (){
this.model.set({postalCode: '1'});
this.model.set({postalCode: '1'}, {validate: true});

@@ -409,3 +409,3 @@ refute(this.model.isValid());

"and violating the second validator the model is invalid": function (){
this.model.set({postalCode: 'ab'});
this.model.set({postalCode: 'ab'}, {validate: true});

@@ -416,3 +416,3 @@ refute(this.model.isValid());

"and violating the last validator the model is invalid": function (){
this.model.set({postalCode: '12345'});
this.model.set({postalCode: '12345'}, {validate: true});

@@ -423,3 +423,3 @@ refute(this.model.isValid());

"and conforming to all validators the model is valid": function (){
this.model.set({postalCode: '123'});
this.model.set({postalCode: '123'}, {validate: true});

@@ -472,4 +472,4 @@ assert(this.model.isValid());

setUp: function() {
this.model.set({one:1});
this.model.set({two:2});
this.model.set({one:1}, {validate: true});
this.model.set({two:2}, {validate: true});
},

@@ -488,5 +488,5 @@

setUp: function() {
this.model.set({one:1});
this.model.set({two:2});
this.model.set({one:2});
this.model.set({one:1}, {validate: true});
this.model.set({two:2}, {validate: true});
this.model.set({one:2}, {validate: true});
},

@@ -519,4 +519,4 @@

"and conforming to all validators the model is valid": function (){
this.model.set({age: 12});
this.model.set({name: 'Jack'});
this.model.set({age: 12}, {validate: true});
this.model.set({name: 'Jack'}, {validate: true});

@@ -523,0 +523,0 @@ this.model.validate();

@@ -32,3 +32,3 @@ buster.testCase("isValid", {

"returns true when model is valid": function() {
this.model.set({name: 'name'});
this.model.set({name: 'name'}, {validate: true});

@@ -39,3 +39,3 @@ assert(this.model.isValid());

"returns false when model is invalid": function() {
this.model.set({name: ''});
this.model.set({name: ''}, {validate: true});

@@ -67,3 +67,3 @@ refute(this.model.isValid());

"returns true when attribute is valid": function() {
this.model.set({name: 'name'}, { silent:true });
this.model.set({name: 'name'});

@@ -94,3 +94,3 @@ assert(this.model.isValid('name'));

"returns false when one attribute is invalid": function() {
this.model.set({name: 'name'}, { silent:true });
this.model.set({name: 'name'});

@@ -101,3 +101,3 @@ refute(this.model.isValid(['name', 'age']));

"returns true when all attributes are valid": function() {
this.model.set({name: 'name', age: 1 }, { silent:true });
this.model.set({name: 'name', age: 1 });

@@ -104,0 +104,0 @@ assert(this.model.isValid(['name', 'age']));

@@ -24,5 +24,3 @@ buster.testCase("Mixin validation", {

// This breaks in v0.9.9 since validation is called from ctor.
// Will change i v.next of BB
"//isValid is undefined when no validation has occurred": function() {
"isValid is undefined when no validation has occurred": function() {
refute.defined(new this.Model().isValid());

@@ -36,3 +34,3 @@ },

"isValid is true when model is valid": function() {
this.model.set({name: 'name'},{silent:true});
this.model.set({name: 'name'});

@@ -43,11 +41,11 @@ assert.equals(true, this.model.isValid(true));

"refutes setting invalid value": function() {
refute(this.model.set({name: ''}));
refute(this.model.set({name: ''}, {validate: true}));
},
"succeeds setting valid value": function() {
assert(this.model.set({name: 'name'}));
assert(this.model.set({name: 'name'}, {validate: true}));
},
"when forcing update succeeds setting invalid value": function() {
assert(this.model.set({name:''}, {forceUpdate: true}));
assert(this.model.set({name:''}, {forceUpdate: true, validate: true}));
},

@@ -69,3 +67,3 @@

"succeeds setting invalid value when forcing update globally": function() {
assert(this.model.set({name:''}));
assert(this.model.set({name:''}, {validate: true}));
}

@@ -80,5 +78,5 @@ },

"it should not complain": function() {
assert(this.model.set({someAttr: 'someValue'}));
assert(this.model.set({someAttr: 'someValue'}, {validate: true}));
}
}
});

@@ -31,3 +31,3 @@ buster.testCase('Nested validation', {

}
});
}, {validate: true});
},

@@ -62,3 +62,3 @@

}
});
}, {validate: true});
},

@@ -119,3 +119,3 @@

}
});
}, {validate: true});
},

@@ -152,3 +152,3 @@

}
});
}, {validate: true});
},

@@ -214,3 +214,3 @@

}
});
}, {validate: true});
},

@@ -251,3 +251,3 @@

}
});
}, {validate: true});
},

@@ -278,3 +278,37 @@

}
},
"nested models and collections": {
setUp: function () {
this.valid = this.spy();
this.invalid = this.spy();
var Model = Backbone.Model.extend({
});
var Collection = Backbone.Collection.extend({
model: Model
});
this.model = new Model();
this.model.set({
model: this.model,
collection: new Collection([this.model])
});
this.view = new Backbone.View({model: this.model});
Backbone.Validation.bind(this.view, {
invalid: this.invalid,
valid: this.valid
});
this.result = this.model.set({
foo: 'bar'
}, {validate: true});
},
"are ignored": function() {
assert(this.result);
}
}
});

@@ -23,8 +23,8 @@ var buster = require('buster'),

"Passes validation": function () {
assert(this.model.set({name:'Name'}));
assert(this.model.set({name:'Name'}, {validate: true}));
},
"Fails validation": function () {
refute(this.model.set({name:''}));
refute(this.model.set({name:''}, {validate: true}));
}
});

@@ -24,7 +24,7 @@ buster.testCase("acceptance validator", {

"has default error message": function(done) {
this.model.bind('error', function(model, error){
this.model.bind('validated:invalid', function(model, error){
assert.equals({agree: 'Agree must be accepted'}, error);
done();
});
this.model.set({agree:false});
this.model.set({agree:false}, {validate: true});
},

@@ -35,3 +35,3 @@

agree: 'non-boolean'
}));
}, {validate: true}));
},

@@ -42,3 +42,3 @@

agree: 'true'
}));
}, {validate: true}));
},

@@ -49,3 +49,3 @@

agree: false
}));
}, {validate: true}));
},

@@ -56,4 +56,4 @@

agree: true
}));
}, {validate: true}));
}
});

@@ -29,7 +29,7 @@ buster.testCase("equalTo validator", {

"has default error message": function(done) {
this.model.bind('error', function(model, error){
this.model.bind('validated:invalid', function(model, error){
assert.equals({passwordRepeat: 'Password repeat must be the same as Password'}, error);
done();
});
this.model.set({passwordRepeat:'123'});
this.model.set({passwordRepeat:'123'}, {validate: true});
},

@@ -40,3 +40,3 @@

passwordRepeat: 'password'
}));
}, {validate: true}));
},

@@ -47,3 +47,3 @@

passwordRepeat: 'error'
}));
}, {validate: true}));
},

@@ -54,3 +54,3 @@

passwordRepeat: 'Password'
}));
}, {validate: true}));
},

@@ -62,4 +62,4 @@

passwordRepeat: 'a'
}));
}, {validate: true}));
}
});

@@ -24,7 +24,7 @@ buster.testCase("length validator", {

"has default error message": function(done) {
this.model.bind('error', function(model, error){
this.model.bind('validated:invalid', function(model, error){
assert.equals({postalCode: 'Postal code must be 2 characters'}, error);
done();
});
this.model.set({postalCode:''});
this.model.set({postalCode:''}, {validate: true});
},

@@ -35,3 +35,3 @@

postalCode: 'a'
}));
}, {validate: true}));
},

@@ -42,3 +42,3 @@

postalCode: 'aaa'
}));
}, {validate: true}));
},

@@ -49,3 +49,3 @@

postalCode: 'aa'
}));
}, {validate: true}));
},

@@ -57,3 +57,3 @@

postalCode: undefined
}));
}, {validate: true}));
},

@@ -64,3 +64,3 @@

postalCode: null
}));
}, {validate: true}));
}

@@ -77,3 +77,3 @@ },

postalCode: null
}));
}, {validate: true}));
},

@@ -84,3 +84,3 @@

postalCode: undefined
}));
}, {validate: true}));
}

@@ -97,3 +97,3 @@ },

postalCode: undefined
}));
}, {validate: true}));
},

@@ -104,5 +104,5 @@

postalCode: null
}));
}, {validate: true}));
}
}
});

@@ -24,7 +24,7 @@ buster.testCase("max validator", {

"has default error message": function(done) {
this.model.bind('error', function(model, error){
this.model.bind('validated:invalid', function(model, error){
assert.equals({age: 'Age must be less than or equal to 10'}, error);
done();
});
this.model.set({age:11});
this.model.set({age:11}, {validate: true});
},

@@ -35,3 +35,3 @@

age: 11
}));
}, {validate: true}));
},

@@ -42,3 +42,3 @@

age: '10error'
}));
}, {validate: true}));
},

@@ -49,3 +49,3 @@

age: 10
}));
}, {validate: true}));
},

@@ -56,3 +56,3 @@

age: 5
}));
}, {validate: true}));
},

@@ -63,3 +63,3 @@

age: '10'
}));
}, {validate: true}));
},

@@ -71,3 +71,3 @@

age: undefined
}));
}, {validate: true}));
},

@@ -78,3 +78,3 @@

age: null
}));
}, {validate: true}));
}

@@ -91,3 +91,3 @@ },

age: null
}));
}, {validate: true}));
},

@@ -98,3 +98,3 @@

age: undefined
}));
}, {validate: true}));
}

@@ -111,3 +111,3 @@ },

age: undefined
}));
}, {validate: true}));
},

@@ -118,5 +118,5 @@

age: null
}));
}, {validate: true}));
}
}
});

@@ -24,7 +24,7 @@ buster.testCase("maxLength validator", {

"has default error message": function(done) {
this.model.bind('error', function(model, error){
this.model.bind('validated:invalid', function(model, error){
assert.equals({name: 'Name must be at most 2 characters'}, error);
done();
});
this.model.set({name:'aaa'});
this.model.set({name:'aaa'}, {validate: true});
},

@@ -35,3 +35,3 @@

name: 'aaa'
}));
}, {validate: true}));
},

@@ -42,3 +42,3 @@

name: 'aa'
}));
}, {validate: true}));
},

@@ -49,3 +49,3 @@

name: 'a'
}));
}, {validate: true}));
},

@@ -57,3 +57,3 @@

name: undefined
}));
}, {validate: true}));
},

@@ -64,3 +64,3 @@

name: null
}));
}, {validate: true}));
}

@@ -77,3 +77,3 @@ },

name: null
}));
}, {validate: true}));
},

@@ -84,3 +84,3 @@

name: undefined
}));
}, {validate: true}));
}

@@ -97,3 +97,3 @@ },

name: undefined
}));
}, {validate: true}));
},

@@ -104,5 +104,5 @@

name: null
}));
}, {validate: true}));
}
}
});

@@ -32,3 +32,3 @@ buster.testCase("method validator", {

name: ''
}));
}, {validate: true}));
},

@@ -39,3 +39,3 @@

name: 'backbone'
}));
}, {validate: true}));
},

@@ -46,3 +46,3 @@

name: ''
});
}, {validate: true});
assert.same(this.ctx, this.model);

@@ -52,3 +52,3 @@ },

"second argument is the name of the attribute being validated": function() {
this.model.set({name: ''});
this.model.set({name: ''}, {validate: true});
assert.equals('name', this.attr);

@@ -58,7 +58,7 @@ },

"third argument is a computed model state": function() {
this.model.set({attr: 'attr'}, {silent: true});
this.model.set({attr: 'attr'});
this.model.set({
name: 'name',
age: 1
});
}, {validate: true});

@@ -98,3 +98,3 @@ assert.equals({attr:'attr', name:'name', age:1}, this.computed);

name: ''
}));
}, {validate: true}));
},

@@ -105,3 +105,3 @@

name: 'backbone'
}));
}, {validate: true}));
},

@@ -112,3 +112,3 @@

name: ''
});
}, {validate: true});
assert.same(this.ctx, this.model);

@@ -118,3 +118,3 @@ },

"second argument is the name of the attribute being validated": function() {
this.model.set({name: ''});
this.model.set({name: ''}, {validate: true});
assert.equals('name', this.attr);

@@ -124,7 +124,7 @@ },

"third argument is a computed model state": function() {
this.model.set({attr: 'attr'}, {silent: true});
this.model.set({attr: 'attr'});
this.model.set({
name: 'name',
age: 1
});
}, {validate: true});

@@ -131,0 +131,0 @@ assert.equals({attr:'attr', name:'name', age:1}, this.computed);

@@ -24,7 +24,7 @@ buster.testCase("min validator", {

"has default error message": function(done) {
this.model.bind('error', function(model, error){
this.model.bind('validated:invalid', function(model, error){
assert.equals({age: 'Age must be greater than or equal to 1'}, error);
done();
});
this.model.set({age: 0});
this.model.set({age: 0}, {validate: true});
},

@@ -35,3 +35,3 @@

age: 0
}));
}, {validate: true}));
},

@@ -42,3 +42,3 @@

age: '10error'
}));
}, {validate: true}));
},

@@ -49,3 +49,3 @@

age: 1
}));
}, {validate: true}));
},

@@ -56,3 +56,3 @@

age: 2
}));
}, {validate: true}));
},

@@ -63,3 +63,3 @@

age: '1'
}));
}, {validate: true}));
},

@@ -71,3 +71,3 @@

age: undefined
}));
}, {validate: true}));
},

@@ -78,3 +78,3 @@

age: null
}));
}, {validate: true}));
}

@@ -91,3 +91,3 @@ },

age: null
}));
}, {validate: true}));
},

@@ -98,3 +98,3 @@

age: undefined
}));
}, {validate: true}));
}

@@ -111,3 +111,3 @@ },

age: undefined
}));
}, {validate: true}));
},

@@ -118,5 +118,5 @@

age: null
}));
}, {validate: true}));
}
}
});

@@ -24,7 +24,7 @@ buster.testCase("minLength validator", {

"has default error message": function(done) {
this.model.bind('error', function(model, error){
this.model.bind('validated:invalid', function(model, error){
assert.equals({name: 'Name must be at least 2 characters'}, error);
done();
});
this.model.set({name:''});
this.model.set({name:''}, {validate: true});
},

@@ -35,3 +35,3 @@

name: 'a'
}));
}, {validate: true}));
},

@@ -42,3 +42,3 @@

name: 'aa'
}));
}, {validate: true}));
},

@@ -49,3 +49,3 @@

name: 'aaaa'
}));
}, {validate: true}));
},

@@ -57,3 +57,3 @@

name: undefined
}));
}, {validate: true}));
},

@@ -64,3 +64,3 @@

name: null
}));
}, {validate: true}));
}

@@ -77,3 +77,3 @@ },

name: null
}));
}, {validate: true}));
},

@@ -84,3 +84,3 @@

name: undefined
}));
}, {validate: true}));
}

@@ -97,3 +97,3 @@ },

name: undefined
}));
}, {validate: true}));
},

@@ -104,5 +104,5 @@

name: null
}));
}, {validate: true}));
}
}
});

@@ -32,11 +32,11 @@ buster.testCase("named method validator", {

"is invalid when method returns error message": function() {
refute(this.model.set({name: ''}));
refute(this.model.set({name: ''}, {validate: true}));
},
"is valid when method returns undefined": function() {
assert(this.model.set({name: 'backbone'}));
assert(this.model.set({name: 'backbone'}, {validate: true}));
},
"context is the model": function() {
this.model.set({name: ''});
this.model.set({name: ''}, {validate: true});
assert.same(this.ctx, this.model);

@@ -46,3 +46,3 @@ },

"second argument is the name of the attribute being validated": function() {
this.model.set({name: ''});
this.model.set({name: ''}, {validate: true});
assert.equals('name', this.attr);

@@ -52,7 +52,7 @@ },

"third argument is a computed model state": function() {
this.model.set({attr: 'attr'}, {silent: true});
this.model.set({attr: 'attr'});
this.model.set({
name: 'name',
age: 1
});
}, {validate: true});

@@ -92,11 +92,11 @@ assert.equals({attr:'attr', name:'name', age:1}, this.computed);

"is invalid when method returns error message": function() {
refute(this.model.set({name: ''}));
refute(this.model.set({name: ''}, {validate: true}));
},
"is valid when method returns undefined": function() {
assert(this.model.set({name: 'backbone'}));
assert(this.model.set({name: 'backbone'}, {validate: true}));
},
"context is the model": function() {
this.model.set({name: ''});
this.model.set({name: ''}, {validate: true});
assert.same(this.ctx, this.model);

@@ -106,3 +106,3 @@ },

"second argument is the name of the attribute being validated": function() {
this.model.set({name: ''});
this.model.set({name: ''}, {validate: true});
assert.equals('name', this.attr);

@@ -112,7 +112,7 @@ },

"third argument is a computed model state": function() {
this.model.set({attr: 'attr'}, {silent: true});
this.model.set({attr: 'attr'});
this.model.set({
name: 'name',
age: 1
});
}, {validate: true});

@@ -119,0 +119,0 @@ assert.equals({attr:'attr', name:'name', age:1}, this.computed);

@@ -24,7 +24,7 @@ buster.testCase("oneOf validator", {

"has default error message": function(done) {
this.model.bind('error', function(model, error){
this.model.bind('validated:invalid', function(model, error){
assert.equals({country: 'Country must be one of: Norway, Sweeden' }, error);
done();
});
this.model.set({country:''});
this.model.set({country:''}, {validate: true});
},

@@ -35,3 +35,3 @@

country: 'Norway'
}));
}, {validate: true}));
},

@@ -42,3 +42,3 @@

country: 'Denmark'
}));
}, {validate: true}));
},

@@ -49,3 +49,3 @@

country: 'sweeden'
}));
}, {validate: true}));
},

@@ -57,3 +57,3 @@

country: undefined
}));
}, {validate: true}));
},

@@ -64,3 +64,3 @@

country: null
}));
}, {validate: true}));
}

@@ -77,3 +77,3 @@ },

country: null
}));
}, {validate: true}));
},

@@ -84,3 +84,3 @@

country: undefined
}));
}, {validate: true}));
}

@@ -97,3 +97,3 @@ },

country: undefined
}));
}, {validate: true}));
},

@@ -104,5 +104,5 @@

country: null
}));
}, {validate: true}));
}
}
});

@@ -30,7 +30,7 @@ buster.testCase("pattern validator", {

"has default error message": function(done) {
this.model.bind('error', function(model, error){
this.model.bind('validated:invalid', function(model, error){
assert.equals({email: 'Email must be a valid email'}, error);
done();
});
this.model.set({email:''});
this.model.set({email:''}, {validate: true});
},

@@ -41,3 +41,3 @@

name: 'aaa'
}));
}, {validate: true}));
},

@@ -48,3 +48,3 @@

name: 'test'
}));
}, {validate: true}));
},

@@ -56,3 +56,3 @@

name: undefined
}));
}, {validate: true}));
},

@@ -63,3 +63,3 @@

name: null
}));
}, {validate: true}));
}

@@ -76,3 +76,3 @@ },

name: null
}));
}, {validate: true}));
},

@@ -83,3 +83,3 @@

name: undefined
}));
}, {validate: true}));
}

@@ -96,3 +96,3 @@ },

name: undefined
}));
}, {validate: true}));
},

@@ -103,3 +103,3 @@

name: null
}));
}, {validate: true}));
}

@@ -111,8 +111,8 @@ },

email: 'aaa'
}));
}, {validate: true}));
assert(this.model.set({
email: 'a@example.com'
}));
}, {validate: true}));
}
});

@@ -24,7 +24,7 @@ buster.testCase("range validator", {

"has default error message": function(done) {
this.model.bind('error', function(model, error){
this.model.bind('validated:invalid', function(model, error){
assert.equals({age: 'Age must be between 1 and 10'}, error);
done();
});
this.model.set({age:0});
this.model.set({age:0}, {validate: true});
},

@@ -35,3 +35,3 @@

age: 0
}));
}, {validate: true}));
},

@@ -42,3 +42,3 @@

age: 1
}));
}, {validate: true}));
},

@@ -49,3 +49,3 @@

age: 11
}));
}, {validate: true}));
},

@@ -56,3 +56,3 @@

age: 10
}));
}, {validate: true}));
},

@@ -63,3 +63,3 @@

age: 5
}));
}, {validate: true}));
},

@@ -71,3 +71,3 @@

age: undefined
}));
}, {validate: true}));
},

@@ -78,3 +78,3 @@

age: null
}));
}, {validate: true}));
}

@@ -91,3 +91,3 @@ },

age: null
}));
}, {validate: true}));
},

@@ -98,3 +98,3 @@

age: undefined
}));
}, {validate: true}));
}

@@ -111,3 +111,3 @@ },

age: undefined
}));
}, {validate: true}));
},

@@ -118,5 +118,5 @@

age: null
}));
}, {validate: true}));
}
}
});

@@ -24,7 +24,7 @@ buster.testCase("rangeLength validator", {

"has default error message": function(done) {
this.model.bind('error', function(model, error){
this.model.bind('validated:invalid', function(model, error){
assert.equals({name: 'Name must be between 2 and 4 characters'}, error);
done();
});
this.model.set({name:'a'});
this.model.set({name:'a'}, {validate: true});
},

@@ -35,3 +35,3 @@

name: 'a'
}));
}, {validate: true}));
},

@@ -42,3 +42,3 @@

name: 'aa'
}));
}, {validate: true}));
},

@@ -49,3 +49,3 @@

name: 'aaaaa'
}));
}, {validate: true}));
},

@@ -56,3 +56,3 @@

name: 'aaaa'
}));
}, {validate: true}));
},

@@ -63,3 +63,3 @@

name: 'aaa'
}));
}, {validate: true}));
},

@@ -71,3 +71,3 @@

name: undefined
}));
}, {validate: true}));
},

@@ -78,3 +78,3 @@

name: null
}));
}, {validate: true}));
}

@@ -91,3 +91,3 @@ },

name: null
}));
}, {validate: true}));
},

@@ -98,3 +98,3 @@

name: undefined
}));
}, {validate: true}));
}

@@ -111,3 +111,3 @@ },

name: undefined
}));
}, {validate: true}));
},

@@ -118,5 +118,5 @@

name: null
}));
}, {validate: true}));
}
}
});

@@ -39,7 +39,7 @@ buster.testCase("required validator", {

"has default error message": function(done) {
this.model.bind('error', function(model, error){
this.model.bind('validated:invalid', function(model, error){
assert.equals({name: 'Name is required'}, error);
done();
});
this.model.set({name:''});
this.model.set({name:''}, {validate: true});
},

@@ -50,3 +50,3 @@

name: ''
}));
}, {validate: true}));
},

@@ -57,3 +57,3 @@

name: 'a'
}));
}, {validate: true}));
},

@@ -64,3 +64,3 @@

name: ' '
}));
}, {validate: true}));
},

@@ -71,3 +71,3 @@

name: null
}));
}, {validate: true}));
},

@@ -78,3 +78,3 @@

name: undefined
}));
}, {validate: true}));
},

@@ -85,3 +85,3 @@

agree: false
}));
}, {validate: true}));
},

@@ -92,17 +92,17 @@

agree: true
}));
}, {validate: true}));
},
"required can be specified as a method returning true or false": function() {
this.model.set({name:'aaa'});
this.model.set({name:'aaa'}, {validate: true});
assert(this.model.set({
dependsOnName: undefined
}));
}, {validate: true}));
this.model.set({name:'name'});
this.model.set({name:'name'}, {validate: true});
refute(this.model.set({
dependsOnName: undefined
}));
}, {validate: true}));
},

@@ -113,3 +113,3 @@

dependsOnName: ''
});
}, {validate: true});
assert.same(this.ctx, this.model);

@@ -119,3 +119,3 @@ },

"second argument is the name of the attribute being validated": function() {
this.model.set({dependsOnName: ''});
this.model.set({dependsOnName: ''}, {validate: true});
assert.equals('dependsOnName', this.attr);

@@ -125,7 +125,7 @@ },

"third argument is a computed model state": function() {
this.model.set({attr: 'attr'}, {silent: true});
this.model.set({attr: 'attr'});
this.model.set({
name: 'name',
dependsOnName: 'value'
});
}, {validate: true});

@@ -132,0 +132,0 @@ assert.equals({agree:true, attr:'attr', dependsOnName:'value', name:'name'}, this.computed);

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