Socket
Socket
Sign inDemoInstall

backbone-validator

Package Overview
Dependencies
1
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.8 to 0.0.9

2

backbone-validator-min.js

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

(function(){function e(e){return!i.isUndefined(e)&&!i.isNull(e)&&""!==e}function t(e,t,n){var r,u;for(r in n)if(n.hasOwnProperty(r)&&i.isFunction(a[r])&&(u=a[r](e,t,n[r])))return u}var n,r=this;n="undefined"!=typeof exports?exports:r.validator={},n.VERSION="0.0.8";var i=r._;i||"undefined"==typeof require||(i=require("underscore")),n.REGEXP_EMAIL=/^(([^<>()\[\]\\.,;:\s@\"]+(\.[^<>()\[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,n.REGEXP_URL=/^(https?:\/\/)?([\da-z\.\-]+)\.([a-z\.]{2,6})([\/\w \.\-]*)*\/?$/,n.REGEXP_DOMAIN=/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?.[a-z]{2,4}(.[a-z]{2-4})?/i;var a={required:function(t,n){return e(n)?void 0:'Attribute "'+t+'" is required.'},equal:function(e,t,n){return t!==n?'Attribute "'+e+'" must be equal to "'+n+'" and got "'+t+'".':void 0},regexp:function(e,t,n){return i.isRegExp(n)&&!n.test(t)?'Attribute "'+e+'" didn\'t match regexp. (got: "'+t+'")':void 0},oneOf:function(e,t,n){return-1===i.indexOf(n,t)?'Attribute "'+e+'" must be one of "'+n.join(", ")+'" and got "'+t+'" instead.':void 0},type:function(t,r,a){var u='Attribute "'+t+'" must be of type '+a+' and got value "'+r+'".';if(e(r)){var o;switch(a){case"boolean":o=i.isBoolean(r);break;case"number":o=i.isNumber(r);break;case"string":o=i.isString(r);break;case"date":o=i.isDate(r);break;case"array":o=i.isArray(r);break;case"email":o=n.REGEXP_EMAIL.test(r);break;case"url":o=n.REGEXP_URL.test(r);break;case"domain":o=n.REGEXP_DOMAIN.test(r)}return o?void 0:u}},minLength:function(e,t,n){return i.isString(t)||i.isArray(t)?n>t.length?'Attribute "'+e+'" was expected to have a minimum '+"length of "+n+' and the current value ("'+t+'")'+"has a length of "+t.length+".":void 0:void 0},maxLength:function(e,t,n){return t.length>n?'Attribute "'+e+'" was expected to have a maximum '+"length of "+n+' and the current value ("'+t+'") has a length of '+t.length+".":void 0},custom:function(e,t,n){return i.isFunction(n)&&(msg=n(t))?msg:void 0}};n.create=function(e){return e=e||{},function(n){var r,i;for(r in n)if(n.hasOwnProperty(r)&&(i=t(r,n[r],e[r])))return i}}}).call(this);
!function(){function a(a){return!e.isUndefined(a)&&!e.isNull(a)&&""!==a}function b(a,b,c){var d,g;for(d in c)if(c.hasOwnProperty(d)&&e.isFunction(f[d])&&(g=f[d](a,b,c[d])))return g}var c,d=this;c="undefined"!=typeof exports?exports:d.validator={},c.VERSION="0.0.9";var e=d._;e||"undefined"==typeof require||(e=require("underscore")),c.REGEXP_EMAIL=/^(([^<>()\[\]\\.,;:\s@\"]+(\.[^<>()\[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,c.REGEXP_URL=/^(https?:\/\/)?([\da-z\.\-]+)\.([a-z\.]{2,6})([\/\w \.\-]*)*\/?$/,c.REGEXP_DOMAIN=/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.[a-z]{2,4}(\.[a-z]{2-4})?/i;var f={required:function(b,c){return a(c)?void 0:'Attribute "'+b+'" is required.'},equal:function(a,b,c){return b!==c?'Attribute "'+a+'" must be equal to "'+c+'" and got "'+b+'".':void 0},regexp:function(a,b,c){return e.isRegExp(c)&&!c.test(b)?'Attribute "'+a+'" didn\'t match regexp. (got: "'+b+'")':void 0},oneOf:function(a,b,c){return-1===e.indexOf(c,b)?'Attribute "'+a+'" must be one of "'+c.join(", ")+'" and got "'+b+'" instead.':void 0},type:function(b,d,f){var g='Attribute "'+b+'" must be of type '+f+' and got value "'+d+'".';if(a(d)){var h;switch(f){case"boolean":h=e.isBoolean(d);break;case"number":h=e.isNumber(d);break;case"string":h=e.isString(d);break;case"date":h=e.isDate(d);break;case"array":h=e.isArray(d);break;case"email":h=c.REGEXP_EMAIL.test(d);break;case"url":h=c.REGEXP_URL.test(d);break;case"domain":h=c.REGEXP_DOMAIN.test(d)}return h?void 0:g}},minLength:function(a,b,c){return e.isString(b)||e.isArray(b)?b.length<c?'Attribute "'+a+'" was expected to have a minimum '+"length of "+c+' and the current value ("'+b+'")'+"has a length of "+b.length+".":void 0:void 0},maxLength:function(a,b,c){return b.length>c?'Attribute "'+a+'" was expected to have a maximum '+"length of "+c+' and the current value ("'+b+'") has a length of '+b.length+".":void 0},custom:function(a,b,c){return e.isFunction(c)&&(msg=c(b))?msg:void 0}};c.create=function(a){return a=a||{},function(c){var d,e;for(d in c)if(c.hasOwnProperty(d)&&(e=b(d,c[d],a[d])))return e}}}.call(this);

@@ -28,7 +28,2 @@ /*global module:false*/

}
},
watch: {
files: '<config:jshint.files>',
tasks: 'jshint nodeunit'
}

@@ -39,4 +34,4 @@

// Default task.
grunt.registerTask('default', [ 'jshint', 'nodeunit' ]);
grunt.registerTask('default', [ 'jshint', 'nodeunit', 'uglify' ]);
};

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

// backbone-validator.js 0.0.8
// backbone-validator.js 0.0.9
// (c) 2013 Lupo Montero

@@ -18,3 +18,3 @@ // Licensed under the MIT license.

validator.VERSION = '0.0.8';
validator.VERSION = '0.0.9';

@@ -28,3 +28,3 @@ // Require Underscore, if we're on the server, and it's not already present.

validator.REGEXP_URL = /^(https?:\/\/)?([\da-z\.\-]+)\.([a-z\.]{2,6})([\/\w \.\-]*)*\/?$/;
validator.REGEXP_DOMAIN = /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?.[a-z]{2,4}(.[a-z]{2-4})?/i;
validator.REGEXP_DOMAIN = /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.[a-z]{2,4}(\.[a-z]{2-4})?/i;

@@ -31,0 +31,0 @@ // A helper function to figure out if a value is "something".

{
"name": "backbone-validator",
"version": "0.0.8",
"version": "0.0.9",
"description": "A super simple validator module for Backbone.",
"author": "Lupo Montero <lupo@e-noise.com>",
"author": "Lupo Montero <lupo@enoi.se>",
"repository": {
"type" : "git",
"url" : "https://github.com/lupomontero/backbone-validator.git"
},
"dependencies": {
"underscore": "1.4.4"
"underscore": "1.5.1"
},

@@ -12,5 +16,5 @@ "devDependencies": {

"grunt": "~0.4.1",
"grunt-contrib-nodeunit": "~0.1.2",
"grunt-contrib-jshint": "~0.3.0",
"grunt-contrib-uglify": "~0.2.0"
"grunt-contrib-nodeunit": "~0.2.0",
"grunt-contrib-jshint": "~0.6.4",
"grunt-contrib-uglify": "~0.2.2"
},

@@ -20,3 +24,4 @@ "scripts": {

"test": "grunt nodeunit"
}
},
"engines": { "node": "0.8.x", "node": "0.10.x" }
}
/*globals require, exports */
var
Backbone = require('backbone'),
validator = require('./index'),
var Backbone = require('backbone');
var validator = require('./index');
MyModel = Backbone.Model.extend({
validate: validator.create({
type: { equal: 'user' },
ctime: { type: 'date' },
someRequiredField: { required: true },
firstname: { type: 'string' },
lastname: { type: 'string', minLength: 2, maxLength: 24 },
organisation: { type: 'string', maxLength: 24 },
email: { type: 'email', required: true },
url: { type: 'url' },
an_array: { type: 'array' },
a_non_empty_array: { type: 'array', minLength: 1 }
})
});
var MyModel = Backbone.Model.extend({
validate: validator.create({
type: { equal: 'user' },
ctime: { type: 'date' },
someRequiredField: { required: true },
firstname: { type: 'string' },
lastname: { type: 'string', minLength: 2, maxLength: 24 },
organisation: { type: 'string', maxLength: 24 },
email: { type: 'email', required: true },
url: { type: 'url' },
an_array: { type: 'array' },
a_non_empty_array: { type: 'array', minLength: 1 },
domain: { type: 'domain' }
})
});

@@ -155,1 +155,31 @@ exports.validateAllGood = function (t) {

};
exports.badDomain = function (t) {
var m = new MyModel();
var domains = [ 'not a domain', 'd.d', 'doo.', '$tyu.di', '-djdjn.com' ];
var count = 0;
m.on('invalid', function (m, err) {
t.ok(/must be of type domain/.test(err));
if (++count === domains.length) {
t.done();
}
});
domains.forEach(function (domain) {
m.set('domain', domain, { validate: true });
});
};
exports.goodDomain = function (t) {
var m = new MyModel();
var domains = [ 'pepe.com', 'enoi.se', 'foo.ac.uk', 'aaaaa.com.jp', 'ba.com' ];
var count = 0;
m.on('change', function () {
t.equal(m.get('domain'), domains[count]);
if (++count === domains.length) {
t.done();
}
});
domains.forEach(function (domain) {
m.set('domain', domain, { validate: true });
});
};

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc