diff --git a/dist/commonjs/lgtm/config.js b/dist/commonjs/lgtm/config.js index 94e3ca3..75dcf8f 100644 --- a/dist/commonjs/lgtm/config.js +++ b/dist/commonjs/lgtm/config.js @@ -1,4 +1,6 @@ "use strict"; +/* jshint esnext:true */ + var config = {}; config.defer = function() { diff --git a/dist/commonjs/lgtm/helpers/core.js b/dist/commonjs/lgtm/helpers/core.js index 66fc840..6c17528 100644 --- a/dist/commonjs/lgtm/helpers/core.js +++ b/dist/commonjs/lgtm/helpers/core.js @@ -1,5 +1,7 @@ "use strict"; var ValidatorBuilder = require("../validator_builder"); +/* jshint esnext:true */ + function present(value) { if (typeof value === 'string') { @@ -26,13 +28,13 @@ function checkEmail(value, options) { } // http://stackoverflow.com/a/46181/11236 - var regexp = /^(([^<>()\[\]\\.,;:\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,}))$/ + var regexp = /^(([^<>()\[\]\\.,;:\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,}))$/; return regexp.test(value); } function checkMinLength(minLength) { if (minLength === null || minLength === undefined) { - throw new Error('must specify a min length') + throw new Error('must specify a min length'); } return function(value) { @@ -46,7 +48,7 @@ function checkMinLength(minLength) { function checkMaxLength(maxLength) { if (maxLength === null || maxLength === undefined) { - throw new Error('must specify a max length') + throw new Error('must specify a max length'); } return function(value) { diff --git a/dist/commonjs/lgtm/object_validator.js b/dist/commonjs/lgtm/object_validator.js index 57a837a..951ddbc 100644 --- a/dist/commonjs/lgtm/object_validator.js +++ b/dist/commonjs/lgtm/object_validator.js @@ -8,6 +8,8 @@ var keys = __dependency1__.keys; var forEach = __dependency1__.forEach; var get = __dependency1__.get; var uniq = __dependency1__.uniq; +/* jshint esnext:true */ + function ObjectValidator() { this._validations = {}; @@ -42,7 +44,7 @@ ObjectValidator.prototype = { for (var i = 0; i < dependentAttributes.length; i++) { var attr = dependentAttributes[i]; if (!contains(dependentsForParent, attr)) { - dependentsForParent.push(attr) + dependentsForParent.push(attr); } } }, diff --git a/dist/commonjs/lgtm/utils.js b/dist/commonjs/lgtm/utils.js index 777d431..578287c 100644 --- a/dist/commonjs/lgtm/utils.js +++ b/dist/commonjs/lgtm/utils.js @@ -1,5 +1,7 @@ "use strict"; var config = require("./config"); +/* jshint esnext:true */ + /** * Iteration diff --git a/dist/commonjs/lgtm/validator_builder.js b/dist/commonjs/lgtm/validator_builder.js index 46b5b5e..05e9f70 100644 --- a/dist/commonjs/lgtm/validator_builder.js +++ b/dist/commonjs/lgtm/validator_builder.js @@ -3,6 +3,8 @@ var ObjectValidator = require("./object_validator"); var __dependency1__ = require("./utils"); var getProperties = __dependency1__.getProperties; var all = __dependency1__.all; +/* jshint esnext:true */ + function ValidatorBuilder() { this._validator = new ObjectValidator(); diff --git a/dist/lgtm-standalone.js b/dist/lgtm-standalone.js index 32239fc..81ef6d6 100644 --- a/dist/lgtm-standalone.js +++ b/dist/lgtm-standalone.js @@ -65,6 +65,8 @@ exports.helpers = helpers; exports.ObjectValidator = ObjectValidator; },{"./lgtm/config":3,"./lgtm/helpers/core":4,"./lgtm/object_validator":5,"./lgtm/validator_builder":7}],3:[function(require,module,exports){ "use strict"; +/* jshint esnext:true */ + var config = {}; config.defer = function() { @@ -76,6 +78,8 @@ module.exports = config; },{}],4:[function(require,module,exports){ "use strict"; var ValidatorBuilder = require("../validator_builder"); +/* jshint esnext:true */ + function present(value) { if (typeof value === 'string') { @@ -85,19 +89,30 @@ function present(value) { return value !== '' && value !== null && value !== undefined; } -function checkEmail(value) { +function checkEmail(value, options) { if (typeof value === 'string') { value = value.trim(); } + if (!options) { + options = {}; + } + + if (options.strictCharacters) { + var strictCharactersRegexp = /^[\x20-\x7F]*$/; + if (!strictCharactersRegexp.test(value)) { + return false; + } + } + // http://stackoverflow.com/a/46181/11236 - var regexp = /^(([^<>()\[\]\\.,;:\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,}))$/ + var regexp = /^(([^<>()\[\]\\.,;:\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,}))$/; return regexp.test(value); } function checkMinLength(minLength) { if (minLength === null || minLength === undefined) { - throw new Error('must specify a min length') + throw new Error('must specify a min length'); } return function(value) { @@ -111,7 +126,7 @@ function checkMinLength(minLength) { function checkMaxLength(maxLength) { if (maxLength === null || maxLength === undefined) { - throw new Error('must specify a max length') + throw new Error('must specify a max length'); } return function(value) { @@ -162,6 +177,8 @@ var keys = __dependency1__.keys; var forEach = __dependency1__.forEach; var get = __dependency1__.get; var uniq = __dependency1__.uniq; +/* jshint esnext:true */ + function ObjectValidator() { this._validations = {}; @@ -196,7 +213,7 @@ ObjectValidator.prototype = { for (var i = 0; i < dependentAttributes.length; i++) { var attr = dependentAttributes[i]; if (!contains(dependentsForParent, attr)) { - dependentsForParent.push(attr) + dependentsForParent.push(attr); } } }, @@ -320,6 +337,8 @@ module.exports = ObjectValidator; },{"./config":3,"./utils":6}],6:[function(require,module,exports){ "use strict"; var config = require("./config"); +/* jshint esnext:true */ + /** * Iteration @@ -452,6 +471,8 @@ var ObjectValidator = require("./object_validator"); var __dependency1__ = require("./utils"); var getProperties = __dependency1__.getProperties; var all = __dependency1__.all; +/* jshint esnext:true */ + function ValidatorBuilder() { this._validator = new ObjectValidator(); diff --git a/dist/lgtm.js b/dist/lgtm.js index 88039da..e92f89a 100644 --- a/dist/lgtm.js +++ b/dist/lgtm.js @@ -48,6 +48,8 @@ exports.helpers = helpers; exports.ObjectValidator = ObjectValidator; },{"./lgtm/config":2,"./lgtm/helpers/core":3,"./lgtm/object_validator":4,"./lgtm/validator_builder":6}],2:[function(require,module,exports){ "use strict"; +/* jshint esnext:true */ + var config = {}; config.defer = function() { @@ -59,6 +61,8 @@ module.exports = config; },{}],3:[function(require,module,exports){ "use strict"; var ValidatorBuilder = require("../validator_builder"); +/* jshint esnext:true */ + function present(value) { if (typeof value === 'string') { @@ -68,19 +72,30 @@ function present(value) { return value !== '' && value !== null && value !== undefined; } -function checkEmail(value) { +function checkEmail(value, options) { if (typeof value === 'string') { value = value.trim(); } + if (!options) { + options = {}; + } + + if (options.strictCharacters) { + var strictCharactersRegexp = /^[\x20-\x7F]*$/; + if (!strictCharactersRegexp.test(value)) { + return false; + } + } + // http://stackoverflow.com/a/46181/11236 - var regexp = /^(([^<>()\[\]\\.,;:\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,}))$/ + var regexp = /^(([^<>()\[\]\\.,;:\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,}))$/; return regexp.test(value); } function checkMinLength(minLength) { if (minLength === null || minLength === undefined) { - throw new Error('must specify a min length') + throw new Error('must specify a min length'); } return function(value) { @@ -94,7 +109,7 @@ function checkMinLength(minLength) { function checkMaxLength(maxLength) { if (maxLength === null || maxLength === undefined) { - throw new Error('must specify a max length') + throw new Error('must specify a max length'); } return function(value) { @@ -145,6 +160,8 @@ var keys = __dependency1__.keys; var forEach = __dependency1__.forEach; var get = __dependency1__.get; var uniq = __dependency1__.uniq; +/* jshint esnext:true */ + function ObjectValidator() { this._validations = {}; @@ -179,7 +196,7 @@ ObjectValidator.prototype = { for (var i = 0; i < dependentAttributes.length; i++) { var attr = dependentAttributes[i]; if (!contains(dependentsForParent, attr)) { - dependentsForParent.push(attr) + dependentsForParent.push(attr); } } }, @@ -303,6 +320,8 @@ module.exports = ObjectValidator; },{"./config":2,"./utils":5}],5:[function(require,module,exports){ "use strict"; var config = require("./config"); +/* jshint esnext:true */ + /** * Iteration @@ -435,6 +454,8 @@ var ObjectValidator = require("./object_validator"); var __dependency1__ = require("./utils"); var getProperties = __dependency1__.getProperties; var all = __dependency1__.all; +/* jshint esnext:true */ + function ValidatorBuilder() { this._validator = new ObjectValidator(); diff --git a/src/lgtm/config.js b/src/lgtm/config.js index f72b3d5..47e2aa9 100644 --- a/src/lgtm/config.js +++ b/src/lgtm/config.js @@ -1,3 +1,5 @@ +/* jshint esnext:true */ + var config = {}; config.defer = function() { diff --git a/src/lgtm/helpers/core.js b/src/lgtm/helpers/core.js index fa8ecbd..d45c3fa 100644 --- a/src/lgtm/helpers/core.js +++ b/src/lgtm/helpers/core.js @@ -1,3 +1,5 @@ +/* jshint esnext:true */ + import ValidatorBuilder from '../validator_builder'; function present(value) { @@ -25,13 +27,13 @@ function checkEmail(value, options) { } // http://stackoverflow.com/a/46181/11236 - var regexp = /^(([^<>()\[\]\\.,;:\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,}))$/ + var regexp = /^(([^<>()\[\]\\.,;:\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,}))$/; return regexp.test(value); } function checkMinLength(minLength) { if (minLength === null || minLength === undefined) { - throw new Error('must specify a min length') + throw new Error('must specify a min length'); } return function(value) { @@ -45,7 +47,7 @@ function checkMinLength(minLength) { function checkMaxLength(maxLength) { if (maxLength === null || maxLength === undefined) { - throw new Error('must specify a max length') + throw new Error('must specify a max length'); } return function(value) { diff --git a/src/lgtm/object_validator.js b/src/lgtm/object_validator.js index cee7972..241e017 100644 --- a/src/lgtm/object_validator.js +++ b/src/lgtm/object_validator.js @@ -1,3 +1,5 @@ +/* jshint esnext:true */ + import config from './config'; import { all, resolve, contains, keys, forEach, get, uniq } from './utils'; @@ -34,7 +36,7 @@ ObjectValidator.prototype = { for (var i = 0; i < dependentAttributes.length; i++) { var attr = dependentAttributes[i]; if (!contains(dependentsForParent, attr)) { - dependentsForParent.push(attr) + dependentsForParent.push(attr); } } }, diff --git a/src/lgtm/utils.js b/src/lgtm/utils.js index 3926269..c6b8a07 100644 --- a/src/lgtm/utils.js +++ b/src/lgtm/utils.js @@ -1,3 +1,5 @@ +/* jshint esnext:true */ + import config from './config'; /** diff --git a/src/lgtm/validator_builder.js b/src/lgtm/validator_builder.js index ec106b6..ddfe324 100644 --- a/src/lgtm/validator_builder.js +++ b/src/lgtm/validator_builder.js @@ -1,3 +1,5 @@ +/* jshint esnext:true */ + import ObjectValidator from './object_validator'; import { getProperties, all } from './utils';