diff --git a/dist/amd/resources/de-DE.js b/dist/amd/resources/de-DE.js index 14b15b8e..b0f0a660 100644 --- a/dist/amd/resources/de-DE.js +++ b/dist/amd/resources/de-DE.js @@ -60,6 +60,9 @@ define(['exports', '../validation/utilities'], function (exports, _validationUti NumericValidationRule: function NumericValidationRule(newValue, threshold) { return 'muss eine Nummer sein'; }, + NoSpacesValidationRule: function NoSpacesValidationRule(newValue, threshold) { + return 'darf keine Leerzeichen enthalten'; + }, RegexValidationRule: function RegexValidationRule(newValue, threshold) { return 'ist kein gültiger Wert'; }, @@ -71,6 +74,9 @@ define(['exports', '../validation/utilities'], function (exports, _validationUti }, MediumPasswordValidationRule: function MediumPasswordValidationRule(newValue, threshold) { return 'sollte zumindest ' + _validationUtilities.Utilities.getValue(threshold) + ' der folgenden Gruppen enthalten: Kleinbuchstaben, Großbuchstaben, Zahlen oder Sonderzeichen'; + }, + URLValidationRule: function URLValidationRule(newValue, threshold) { + return 'ist keine gültige URL'; } } }; diff --git a/dist/amd/resources/en-US.js b/dist/amd/resources/en-US.js index 05ae10be..acec56d9 100644 --- a/dist/amd/resources/en-US.js +++ b/dist/amd/resources/en-US.js @@ -72,6 +72,9 @@ define(['exports', '../validation/utilities'], function (exports, _validationUti NumericValidationRule: function NumericValidationRule(newValue, threshold) { return 'needs to be a number'; }, + NoSpacesValidationRule: function NoSpacesValidationRule(newValue, threshold) { + return 'cannot contain spaces'; + }, RegexValidationRule: function RegexValidationRule(newValue, threshold) { return 'not a valid value'; }, @@ -83,6 +86,9 @@ define(['exports', '../validation/utilities'], function (exports, _validationUti }, MediumPasswordValidationRule: function MediumPasswordValidationRule(newValue, threshold) { return 'should contain at least ' + _validationUtilities.Utilities.getValue(threshold) + ' of the following groups: lowercase letters, uppercase letters, digits or special characters'; + }, + URLValidationRule: function URLValidationRule(newValue, threshold) { + return 'is not a valid URL'; } } }; diff --git a/dist/amd/resources/es-MX.js b/dist/amd/resources/es-MX.js index 192b6217..047c8826 100644 --- a/dist/amd/resources/es-MX.js +++ b/dist/amd/resources/es-MX.js @@ -72,6 +72,9 @@ define(['exports', '../validation/utilities'], function (exports, _validationUti NumericValidationRule: function NumericValidationRule(newValue, threshold) { return 'debe ser un numero'; }, + NoSpacesValidationRule: function NoSpacesValidationRule(newValue, threshold) { + return 'no puede contener espacios'; + }, RegexValidationRule: function RegexValidationRule(newValue, threshold) { return 'no es un valor valido'; }, @@ -83,6 +86,9 @@ define(['exports', '../validation/utilities'], function (exports, _validationUti }, MediumPasswordValidationRule: function MediumPasswordValidationRule(newValue, threshold) { return 'debe poseer al menos ' + _validationUtilities.Utilities.getValue(threshold) + ' de las siguientes características: letras minúsculas, letras mayúsculas, dígitos o caracteres especiales'; + }, + URLValidationRule: function URLValidationRule(newValue, threshold) { + return 'no es una URL válida'; } } }; diff --git a/dist/amd/resources/fr-FR.js b/dist/amd/resources/fr-FR.js index 84563bf3..802d5914 100644 --- a/dist/amd/resources/fr-FR.js +++ b/dist/amd/resources/fr-FR.js @@ -72,6 +72,9 @@ define(['exports', '../validation/utilities'], function (exports, _validationUti NumericValidationRule: function NumericValidationRule(newValue, threshold) { return 'doit être une valeur numérique'; }, + NoSpacesValidationRule: function NoSpacesValidationRule(newValue, threshold) { + return 'ne peut pas contenir d\'espaces'; + }, RegexValidationRule: function RegexValidationRule(newValue, threshold) { return 'n\'est pas une valeur valide'; }, @@ -83,6 +86,9 @@ define(['exports', '../validation/utilities'], function (exports, _validationUti }, MediumPasswordValidationRule: function MediumPasswordValidationRule(newValue, threshold) { return 'doit contenir au moins ' + _validationUtilities.Utilities.getValue(threshold) + ' des caractéristiques suivantes : lettres minuscules, lettres majuscules, caractères numériques ou caractères spéciaux'; + }, + URLValidationRule: function URLValidationRule(newValue, threshold) { + return 'est pas un URL valide'; } } }; diff --git a/dist/amd/resources/nl-BE.js b/dist/amd/resources/nl-BE.js index 917b148d..8b0dc2b6 100644 --- a/dist/amd/resources/nl-BE.js +++ b/dist/amd/resources/nl-BE.js @@ -72,6 +72,9 @@ define(['exports', '../validation/utilities'], function (exports, _validationUti NumericValidationRule: function NumericValidationRule(newValue, threshold) { return 'moet een getal zijn'; }, + NoSpacesValidationRule: function NoSpacesValidationRule(newValue, threshold) { + return 'mag geen spaties bevatten'; + }, RegexValidationRule: function RegexValidationRule(newValue, threshold) { return 'is geen geldige waarde'; }, @@ -83,6 +86,9 @@ define(['exports', '../validation/utilities'], function (exports, _validationUti }, MediumPasswordValidationRule: function MediumPasswordValidationRule(newValue, threshold) { return 'moet op zijn minst ' + _validationUtilities.Utilities.getValue(threshold) + ' van de volgende groepen bevatten: letters, hoofdletters, cijfers of speciale tekens'; + }, + URLValidationRule: function URLValidationRule(newValue, threshold) { + return 'is geen geldige URL'; } } }; diff --git a/dist/amd/resources/nl-NL.js b/dist/amd/resources/nl-NL.js index 917b148d..8b0dc2b6 100644 --- a/dist/amd/resources/nl-NL.js +++ b/dist/amd/resources/nl-NL.js @@ -72,6 +72,9 @@ define(['exports', '../validation/utilities'], function (exports, _validationUti NumericValidationRule: function NumericValidationRule(newValue, threshold) { return 'moet een getal zijn'; }, + NoSpacesValidationRule: function NoSpacesValidationRule(newValue, threshold) { + return 'mag geen spaties bevatten'; + }, RegexValidationRule: function RegexValidationRule(newValue, threshold) { return 'is geen geldige waarde'; }, @@ -83,6 +86,9 @@ define(['exports', '../validation/utilities'], function (exports, _validationUti }, MediumPasswordValidationRule: function MediumPasswordValidationRule(newValue, threshold) { return 'moet op zijn minst ' + _validationUtilities.Utilities.getValue(threshold) + ' van de volgende groepen bevatten: letters, hoofdletters, cijfers of speciale tekens'; + }, + URLValidationRule: function URLValidationRule(newValue, threshold) { + return 'is geen geldige URL'; } } }; diff --git a/dist/amd/resources/sv-SE.js b/dist/amd/resources/sv-SE.js index 92f35a5b..4af47dd7 100644 --- a/dist/amd/resources/sv-SE.js +++ b/dist/amd/resources/sv-SE.js @@ -72,6 +72,9 @@ define(['exports', '../validation/utilities'], function (exports, _validationUti NumericValidationRule: function NumericValidationRule(newValue, threshold) { return 'måste vara ett nummer'; }, + NoSpacesValidationRule: function NoSpacesValidationRule(newValue, threshold) { + return 'kan inte innehålla mellanslag'; + }, RegexValidationRule: function RegexValidationRule(newValue, threshold) { return 'är inte ett giltigt värde'; }, @@ -83,6 +86,9 @@ define(['exports', '../validation/utilities'], function (exports, _validationUti }, MediumPasswordValidationRule: function MediumPasswordValidationRule(newValue, threshold) { return 'ska innehålla minst ' + _validationUtilities.Utilities.getValue(threshold) + ' av följande grupperingar: gemener, versaler, siffror eller specialtecken'; + }, + URLValidationRule: function URLValidationRule(newValue, threshold) { + return 'är inte en giltig webbadress'; } } }; diff --git a/dist/amd/resources/tr-TR.js b/dist/amd/resources/tr-TR.js index a9414a57..8b51c0e1 100644 --- a/dist/amd/resources/tr-TR.js +++ b/dist/amd/resources/tr-TR.js @@ -72,6 +72,9 @@ define(['exports', '../validation/utilities'], function (exports, _validationUti NumericValidationRule: function NumericValidationRule(newValue, threshold) { return 'sadece sayı girebilirsiniz'; }, + NoSpacesValidationRule: function NoSpacesValidationRule(newValue, threshold) { + return 'boşluk içeremez'; + }, RegexValidationRule: function RegexValidationRule(newValue, threshold) { return 'geçerli bir değer giriniz'; }, @@ -83,6 +86,9 @@ define(['exports', '../validation/utilities'], function (exports, _validationUti }, MediumPasswordValidationRule: function MediumPasswordValidationRule(newValue, threshold) { return 'küçük harfler, büyük harfler, sayılar veya işaretlerden en az ' + _validationUtilities.Utilities.getValue(threshold) + ' değişik tip olmalı'; + }, + URLValidationRule: function URLValidationRule(newValue, threshold) { + return 'Geçerli bir URL değil'; } } }; diff --git a/dist/amd/validation/path-observer.js b/dist/amd/validation/path-observer.js index 52f3f607..9826469e 100644 --- a/dist/amd/validation/path-observer.js +++ b/dist/amd/validation/path-observer.js @@ -74,7 +74,7 @@ define(['exports', 'aurelia-binding'], function (exports, _aureliaBinding) { PathObserver.prototype.observePart = function observePart(part) { if (part !== this.path[this.path.length - 1]) { - this.observerParts(); + this.observeParts(); } }; diff --git a/dist/amd/validation/validation-config.js b/dist/amd/validation/validation-config.js index f2434ec9..e479c0ff 100644 --- a/dist/amd/validation/validation-config.js +++ b/dist/amd/validation/validation-config.js @@ -59,7 +59,7 @@ define(['exports', '../validation/validation-locale', '../validation/validate-cu _this.changedHandlers.set(id, callback); return { v: function () { - changedHandlers['delete'](id); + _this.changedHandlers['delete'](id); } }; })(); diff --git a/dist/amd/validation/validation-group-builder.js b/dist/amd/validation/validation-group-builder.js index 22bbed12..8fab9acb 100644 --- a/dist/amd/validation/validation-group-builder.js +++ b/dist/amd/validation/validation-group-builder.js @@ -90,6 +90,10 @@ define(['exports', '../validation/validation-rules', '../validation/validation-r return this.passesRule(new _validationValidationRules.EmailValidationRule()); }; + ValidationGroupBuilder.prototype.isURL = function isURL() { + return this.passesRule(new _validationValidationRules.URLValidationRule()); + }; + ValidationGroupBuilder.prototype.hasMinLength = function hasMinLength(minimumValue) { return this.passesRule(new _validationValidationRules.MinimumLengthValidationRule(minimumValue)); }; @@ -106,6 +110,10 @@ define(['exports', '../validation/validation-rules', '../validation/validation-r return this.passesRule(new _validationValidationRules.NumericValidationRule()); }; + ValidationGroupBuilder.prototype.containsNoSpaces = function containsNoSpaces() { + return this.passesRule(new _validationValidationRules.NoSpacesValidationRule()); + }; + ValidationGroupBuilder.prototype.containsOnlyDigits = function containsOnlyDigits() { return this.passesRule(new _validationValidationRules.DigitValidationRule()); }; diff --git a/dist/amd/validation/validation-group.js b/dist/amd/validation/validation-group.js index 56198bcf..2e29d3e2 100644 --- a/dist/amd/validation/validation-group.js +++ b/dist/amd/validation/validation-group.js @@ -211,6 +211,10 @@ define(['exports', '../validation/validation-group-builder', '../validation/vali return this.builder.isEmail(); }; + ValidationGroup.prototype.isURL = function isURL() { + return this.builder.isURL(); + }; + ValidationGroup.prototype.isIn = function isIn(collection) { return this.builder.isIn(collection); }; @@ -231,6 +235,10 @@ define(['exports', '../validation/validation-group-builder', '../validation/vali return this.builder.isNumber(); }; + ValidationGroup.prototype.containsNoSpaces = function containsNoSpaces() { + return this.builder.containsNoSpaces(); + }; + ValidationGroup.prototype.containsOnlyDigits = function containsOnlyDigits() { return this.builder.containsOnlyDigits(); }; diff --git a/dist/amd/validation/validation-property.js b/dist/amd/validation/validation-property.js index 6ca1a94a..e4a5ffd9 100644 --- a/dist/amd/validation/validation-property.js +++ b/dist/amd/validation/validation-property.js @@ -45,7 +45,7 @@ define(['exports', '../validation/validation-rules-collection', '../validation/p } ValidationProperty.prototype.addValidationRule = function addValidationRule(validationRule) { - if (validationRule.validate === undefined) throw new exception('That\'s not a valid validationRule'); + if (validationRule.validate === undefined) throw new Error('That\'s not a valid validationRule'); this.collectionOfValidationRules.addValidationRule(validationRule); this.validateCurrentValue(false); }; diff --git a/dist/amd/validation/validation-rules-collection.js b/dist/amd/validation/validation-rules-collection.js index 483cd4f4..0b01e73e 100644 --- a/dist/amd/validation/validation-rules-collection.js +++ b/dist/amd/validation/validation-rules-collection.js @@ -90,7 +90,7 @@ define(['exports', '../validation/utilities', '../validation/validation-locale'] }; ValidationRulesCollection.prototype.addValidationRule = function addValidationRule(validationRule) { - if (validationRule.validate === undefined) throw new exception('That\'s not a valid validationRule'); + if (validationRule.validate === undefined) throw new Error('That\'s not a valid validationRule'); this.validationRules.push(validationRule); }; diff --git a/dist/amd/validation/validation-rules.js b/dist/amd/validation/validation-rules.js index fcecd45c..2165ef2c 100644 --- a/dist/amd/validation/validation-rules.js +++ b/dist/amd/validation/validation-rules.js @@ -72,13 +72,174 @@ define(['exports', '../validation/utilities', '../validation/validation-locale'] exports.ValidationRule = ValidationRule; - var EmailValidationRule = (function (_ValidationRule) { - function EmailValidationRule() { + var URLValidationRule = (function (_ValidationRule) { + function URLValidationRule(threshold) { var _this2 = this; + _classCallCheck(this, URLValidationRule); + + var default_url_options = { + protocols: ['http', 'https', 'ftp'], + require_tld: true, + require_protocol: false, + allow_underscores: true, + allow_trailing_dot: false, + allow_protocol_relative_urls: true + }; + if (threshold === undefined) { + threshold = default_url_options; + } + + _ValidationRule.call(this, threshold, function (newValue, threshold) { + var url = newValue; + if (!url || url.length >= 2083 || /\s/.test(url)) { + return false; + } + if (url.indexOf('mailto:') === 0) { + return false; + } + var protocol, auth, host, hostname, port, port_str, split; + split = url.split('://'); + if (split.length > 1) { + protocol = split.shift(); + if (threshold.protocols.indexOf(protocol) === -1) { + return false; + } + } else if (threshold.require_protocol) { + return false; + } else if (threshold.allow_protocol_relative_urls && url.substr(0, 2) === '//') { + split[0] = url.substr(2); + } + url = split.join('://'); + split = url.split('#'); + url = split.shift(); + + split = url.split('?'); + url = split.shift(); + + split = url.split('/'); + url = split.shift(); + split = url.split('@'); + if (split.length > 1) { + auth = split.shift(); + if (auth.indexOf(':') >= 0 && auth.split(':').length > 2) { + return false; + } + } + hostname = split.join('@'); + split = hostname.split(':'); + host = split.shift(); + if (split.length) { + port_str = split.join(':'); + port = parseInt(port_str, 10); + if (!/^[0-9]+$/.test(port_str) || port <= 0 || port > 65535) { + return false; + } + } + if (!_this2.isIP(host) && !_this2.isFQDN(host, threshold) && host !== 'localhost') { + return false; + } + if (threshold.host_whitelist && threshold.host_whitelist.indexOf(host) === -1) { + return false; + } + if (threshold.host_blacklist && threshold.host_blacklist.indexOf(host) !== -1) { + return false; + } + return true; + }); + this.isIP = function (str, version) { + var ipv4Maybe = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/, + ipv6Block = /^[0-9A-F]{1,4}$/i; + + if (!version) { + return this.isIP(str, 4) || this.isIP(str, 6); + } else if (version === 4) { + if (!ipv4Maybe.test(str)) { + return false; + } + var parts = str.split('.').sort(function (a, b) { + return a - b; + }); + return parts[3] <= 255; + } else if (version === 6) { + var blocks = str.split(':'); + var foundOmissionBlock = false; + + if (blocks.length > 8) return false; + + if (str === '::') { + return true; + } else if (str.substr(0, 2) === '::') { + blocks.shift(); + blocks.shift(); + foundOmissionBlock = true; + } else if (str.substr(str.length - 2) === '::') { + blocks.pop(); + blocks.pop(); + foundOmissionBlock = true; + } + + for (var i = 0; i < blocks.length; ++i) { + if (blocks[i] === '' && i > 0 && i < blocks.length - 1) { + if (foundOmissionBlock) return false; + foundOmissionBlock = true; + } else if (!ipv6Block.test(blocks[i])) { + return false; + } + } + + if (foundOmissionBlock) { + return blocks.length >= 1; + } else { + return blocks.length === 8; + } + } + return false; + }; + this.isFQDN = function (str, options) { + if (options.allow_trailing_dot && str[str.length - 1] === '.') { + str = str.substring(0, str.length - 1); + } + var parts = str.split('.'); + if (options.require_tld) { + var tld = parts.pop(); + if (!parts.length || !/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) { + return false; + } + } + for (var part, i = 0; i < parts.length; i++) { + part = parts[i]; + if (options.allow_underscores) { + if (part.indexOf('__') >= 0) { + return false; + } + part = part.replace(/_/g, ''); + } + if (!/^[a-z\u00a1-\uffff0-9-]+$/i.test(part)) { + return false; + } + if (part[0] === '-' || part[part.length - 1] === '-' || part.indexOf('---') >= 0) { + return false; + } + } + return true; + }; + } + + _inherits(URLValidationRule, _ValidationRule); + + return URLValidationRule; + })(ValidationRule); + + exports.URLValidationRule = URLValidationRule; + + var EmailValidationRule = (function (_ValidationRule2) { + function EmailValidationRule() { + var _this3 = this; + _classCallCheck(this, EmailValidationRule); - _ValidationRule.call(this, null, function (newValue, threshold) { + _ValidationRule2.call(this, null, function (newValue, threshold) { if (/\s/.test(newValue)) { return false; } @@ -86,10 +247,10 @@ define(['exports', '../validation/utilities', '../validation/validation-locale'] var domain = parts.pop(); var user = parts.join('@'); - if (!_this2.isFQDN(domain)) { + if (!_this3.isFQDN(domain)) { return false; } - return _this2.emailUserUtf8Regex.test(user); + return _this3.emailUserUtf8Regex.test(user); }); this.emailUserUtf8Regex = /^((([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)))$/i; this.isFQDN = function (str) { @@ -111,103 +272,103 @@ define(['exports', '../validation/utilities', '../validation/validation-locale'] }; } - _inherits(EmailValidationRule, _ValidationRule); + _inherits(EmailValidationRule, _ValidationRule2); return EmailValidationRule; })(ValidationRule); exports.EmailValidationRule = EmailValidationRule; - var MinimumLengthValidationRule = (function (_ValidationRule2) { + var MinimumLengthValidationRule = (function (_ValidationRule3) { function MinimumLengthValidationRule(minimumLength) { _classCallCheck(this, MinimumLengthValidationRule); - _ValidationRule2.call(this, minimumLength, function (newValue, minimumLength) { + _ValidationRule3.call(this, minimumLength, function (newValue, minimumLength) { return newValue.length !== undefined && newValue.length >= minimumLength; }); } - _inherits(MinimumLengthValidationRule, _ValidationRule2); + _inherits(MinimumLengthValidationRule, _ValidationRule3); return MinimumLengthValidationRule; })(ValidationRule); exports.MinimumLengthValidationRule = MinimumLengthValidationRule; - var MaximumLengthValidationRule = (function (_ValidationRule3) { + var MaximumLengthValidationRule = (function (_ValidationRule4) { function MaximumLengthValidationRule(maximumLength) { _classCallCheck(this, MaximumLengthValidationRule); - _ValidationRule3.call(this, maximumLength, function (newValue, maximumLength) { + _ValidationRule4.call(this, maximumLength, function (newValue, maximumLength) { return newValue.length !== undefined && newValue.length <= maximumLength; }); } - _inherits(MaximumLengthValidationRule, _ValidationRule3); + _inherits(MaximumLengthValidationRule, _ValidationRule4); return MaximumLengthValidationRule; })(ValidationRule); exports.MaximumLengthValidationRule = MaximumLengthValidationRule; - var BetweenLengthValidationRule = (function (_ValidationRule4) { + var BetweenLengthValidationRule = (function (_ValidationRule5) { function BetweenLengthValidationRule(minimumLength, maximumLength) { _classCallCheck(this, BetweenLengthValidationRule); - _ValidationRule4.call(this, { minimumLength: minimumLength, maximumLength: maximumLength }, function (newValue, threshold) { + _ValidationRule5.call(this, { minimumLength: minimumLength, maximumLength: maximumLength }, function (newValue, threshold) { return newValue.length !== undefined && newValue.length >= threshold.minimumLength && newValue.length <= threshold.maximumLength; }); } - _inherits(BetweenLengthValidationRule, _ValidationRule4); + _inherits(BetweenLengthValidationRule, _ValidationRule5); return BetweenLengthValidationRule; })(ValidationRule); exports.BetweenLengthValidationRule = BetweenLengthValidationRule; - var CustomFunctionValidationRule = (function (_ValidationRule5) { + var CustomFunctionValidationRule = (function (_ValidationRule6) { function CustomFunctionValidationRule(customFunction, threshold) { _classCallCheck(this, CustomFunctionValidationRule); - _ValidationRule5.call(this, threshold, customFunction); + _ValidationRule6.call(this, threshold, customFunction); } - _inherits(CustomFunctionValidationRule, _ValidationRule5); + _inherits(CustomFunctionValidationRule, _ValidationRule6); return CustomFunctionValidationRule; })(ValidationRule); exports.CustomFunctionValidationRule = CustomFunctionValidationRule; - var NumericValidationRule = (function (_ValidationRule6) { + var NumericValidationRule = (function (_ValidationRule7) { function NumericValidationRule() { _classCallCheck(this, NumericValidationRule); - _ValidationRule6.call(this, null, function (newValue, threshold, locale) { + _ValidationRule7.call(this, null, function (newValue, threshold, locale) { var numericRegex = locale.setting('numericRegex'); var floatValue = parseFloat(newValue); - return !Number.isNaN(parseFloat(floatValue)) && Number.isFinite(floatValue) && numericRegex.test(newValue); + return !Number.isNaN(parseFloat(newValue)) && Number.isFinite(floatValue) && numericRegex.test(newValue); }); } - _inherits(NumericValidationRule, _ValidationRule6); + _inherits(NumericValidationRule, _ValidationRule7); return NumericValidationRule; })(ValidationRule); exports.NumericValidationRule = NumericValidationRule; - var RegexValidationRule = (function (_ValidationRule7) { + var RegexValidationRule = (function (_ValidationRule8) { function RegexValidationRule(regex) { _classCallCheck(this, RegexValidationRule); - _ValidationRule7.call(this, regex, function (newValue, regex) { + _ValidationRule8.call(this, regex, function (newValue, regex) { return regex.test(newValue); }); } - _inherits(RegexValidationRule, _ValidationRule7); + _inherits(RegexValidationRule, _ValidationRule8); return RegexValidationRule; })(ValidationRule); @@ -228,186 +389,205 @@ define(['exports', '../validation/utilities', '../validation/validation-locale'] exports.ContainsOnlyValidationRule = ContainsOnlyValidationRule; - var MinimumValueValidationRule = (function (_ValidationRule8) { + var MinimumValueValidationRule = (function (_ValidationRule9) { function MinimumValueValidationRule(minimumValue) { _classCallCheck(this, MinimumValueValidationRule); - _ValidationRule8.call(this, minimumValue, function (newValue, minimumValue) { + _ValidationRule9.call(this, minimumValue, function (newValue, minimumValue) { return _validationUtilities.Utilities.getValue(minimumValue) < newValue; }); } - _inherits(MinimumValueValidationRule, _ValidationRule8); + _inherits(MinimumValueValidationRule, _ValidationRule9); return MinimumValueValidationRule; })(ValidationRule); exports.MinimumValueValidationRule = MinimumValueValidationRule; - var MinimumInclusiveValueValidationRule = (function (_ValidationRule9) { + var MinimumInclusiveValueValidationRule = (function (_ValidationRule10) { function MinimumInclusiveValueValidationRule(minimumValue) { _classCallCheck(this, MinimumInclusiveValueValidationRule); - _ValidationRule9.call(this, minimumValue, function (newValue, minimumValue) { + _ValidationRule10.call(this, minimumValue, function (newValue, minimumValue) { return _validationUtilities.Utilities.getValue(minimumValue) <= newValue; }); } - _inherits(MinimumInclusiveValueValidationRule, _ValidationRule9); + _inherits(MinimumInclusiveValueValidationRule, _ValidationRule10); return MinimumInclusiveValueValidationRule; })(ValidationRule); exports.MinimumInclusiveValueValidationRule = MinimumInclusiveValueValidationRule; - var MaximumValueValidationRule = (function (_ValidationRule10) { + var MaximumValueValidationRule = (function (_ValidationRule11) { function MaximumValueValidationRule(maximumValue) { _classCallCheck(this, MaximumValueValidationRule); - _ValidationRule10.call(this, maximumValue, function (newValue, maximumValue) { + _ValidationRule11.call(this, maximumValue, function (newValue, maximumValue) { return newValue < _validationUtilities.Utilities.getValue(maximumValue); }); } - _inherits(MaximumValueValidationRule, _ValidationRule10); + _inherits(MaximumValueValidationRule, _ValidationRule11); return MaximumValueValidationRule; })(ValidationRule); exports.MaximumValueValidationRule = MaximumValueValidationRule; - var MaximumInclusiveValueValidationRule = (function (_ValidationRule11) { + var MaximumInclusiveValueValidationRule = (function (_ValidationRule12) { function MaximumInclusiveValueValidationRule(maximumValue) { _classCallCheck(this, MaximumInclusiveValueValidationRule); - _ValidationRule11.call(this, maximumValue, function (newValue, maximumValue) { + _ValidationRule12.call(this, maximumValue, function (newValue, maximumValue) { return newValue <= _validationUtilities.Utilities.getValue(maximumValue); }); } - _inherits(MaximumInclusiveValueValidationRule, _ValidationRule11); + _inherits(MaximumInclusiveValueValidationRule, _ValidationRule12); return MaximumInclusiveValueValidationRule; })(ValidationRule); exports.MaximumInclusiveValueValidationRule = MaximumInclusiveValueValidationRule; - var BetweenValueValidationRule = (function (_ValidationRule12) { + var BetweenValueValidationRule = (function (_ValidationRule13) { function BetweenValueValidationRule(minimumValue, maximumValue) { _classCallCheck(this, BetweenValueValidationRule); - _ValidationRule12.call(this, { minimumValue: minimumValue, maximumValue: maximumValue }, function (newValue, threshold) { + _ValidationRule13.call(this, { minimumValue: minimumValue, maximumValue: maximumValue }, function (newValue, threshold) { return _validationUtilities.Utilities.getValue(threshold.minimumValue) <= newValue && newValue <= _validationUtilities.Utilities.getValue(threshold.maximumValue); }); } - _inherits(BetweenValueValidationRule, _ValidationRule12); + _inherits(BetweenValueValidationRule, _ValidationRule13); return BetweenValueValidationRule; })(ValidationRule); exports.BetweenValueValidationRule = BetweenValueValidationRule; - var DigitValidationRule = (function (_ValidationRule13) { + var DigitValidationRule = (function (_ValidationRule14) { function DigitValidationRule() { - var _this3 = this; + var _this4 = this; _classCallCheck(this, DigitValidationRule); - _ValidationRule13.call(this, null, function (newValue, threshold) { - return _this3.digitRegex.test(newValue); + _ValidationRule14.call(this, null, function (newValue, threshold) { + return _this4.digitRegex.test(newValue); }); this.digitRegex = /^\d+$/; } - _inherits(DigitValidationRule, _ValidationRule13); + _inherits(DigitValidationRule, _ValidationRule14); return DigitValidationRule; })(ValidationRule); exports.DigitValidationRule = DigitValidationRule; - var AlphaNumericValidationRule = (function (_ValidationRule14) { + var NoSpacesValidationRule = (function (_ValidationRule15) { + function NoSpacesValidationRule() { + var _this5 = this; + + _classCallCheck(this, NoSpacesValidationRule); + + _ValidationRule15.call(this, null, function (newValue, threshold) { + return _this5.regex.test(newValue); + }); + this.regex = /^\S*$/; + } + + _inherits(NoSpacesValidationRule, _ValidationRule15); + + return NoSpacesValidationRule; + })(ValidationRule); + + exports.NoSpacesValidationRule = NoSpacesValidationRule; + + var AlphaNumericValidationRule = (function (_ValidationRule16) { function AlphaNumericValidationRule() { - var _this4 = this; + var _this6 = this; _classCallCheck(this, AlphaNumericValidationRule); - _ValidationRule14.call(this, null, function (newValue, threshold) { - return _this4.alphaNumericRegex.test(newValue); + _ValidationRule16.call(this, null, function (newValue, threshold) { + return _this6.alphaNumericRegex.test(newValue); }); this.alphaNumericRegex = /^[a-z0-9]+$/i; } - _inherits(AlphaNumericValidationRule, _ValidationRule14); + _inherits(AlphaNumericValidationRule, _ValidationRule16); return AlphaNumericValidationRule; })(ValidationRule); exports.AlphaNumericValidationRule = AlphaNumericValidationRule; - var AlphaValidationRule = (function (_ValidationRule15) { + var AlphaValidationRule = (function (_ValidationRule17) { function AlphaValidationRule() { - var _this5 = this; + var _this7 = this; _classCallCheck(this, AlphaValidationRule); - _ValidationRule15.call(this, null, function (newValue, threshold) { - return _this5.alphaRegex.test(newValue); + _ValidationRule17.call(this, null, function (newValue, threshold) { + return _this7.alphaRegex.test(newValue); }); this.alphaRegex = /^[a-z]+$/i; } - _inherits(AlphaValidationRule, _ValidationRule15); + _inherits(AlphaValidationRule, _ValidationRule17); return AlphaValidationRule; })(ValidationRule); exports.AlphaValidationRule = AlphaValidationRule; - var AlphaOrWhitespaceValidationRule = (function (_ValidationRule16) { + var AlphaOrWhitespaceValidationRule = (function (_ValidationRule18) { function AlphaOrWhitespaceValidationRule() { - var _this6 = this; + var _this8 = this; _classCallCheck(this, AlphaOrWhitespaceValidationRule); - _ValidationRule16.call(this, null, function (newValue, threshold) { - return _this6.alphaNumericRegex.test(newValue); + _ValidationRule18.call(this, null, function (newValue, threshold) { + return _this8.alphaNumericRegex.test(newValue); }); this.alphaNumericRegex = /^[a-z\s]+$/i; } - _inherits(AlphaOrWhitespaceValidationRule, _ValidationRule16); + _inherits(AlphaOrWhitespaceValidationRule, _ValidationRule18); return AlphaOrWhitespaceValidationRule; })(ValidationRule); exports.AlphaOrWhitespaceValidationRule = AlphaOrWhitespaceValidationRule; - var AlphaNumericOrWhitespaceValidationRule = (function (_ValidationRule17) { + var AlphaNumericOrWhitespaceValidationRule = (function (_ValidationRule19) { function AlphaNumericOrWhitespaceValidationRule() { - var _this7 = this; + var _this9 = this; _classCallCheck(this, AlphaNumericOrWhitespaceValidationRule); - _ValidationRule17.call(this, null, function (newValue, threshold) { - return _this7.alphaNumericRegex.test(newValue); + _ValidationRule19.call(this, null, function (newValue, threshold) { + return _this9.alphaNumericRegex.test(newValue); }); this.alphaNumericRegex = /^[a-z0-9\s]+$/i; } - _inherits(AlphaNumericOrWhitespaceValidationRule, _ValidationRule17); + _inherits(AlphaNumericOrWhitespaceValidationRule, _ValidationRule19); return AlphaNumericOrWhitespaceValidationRule; })(ValidationRule); exports.AlphaNumericOrWhitespaceValidationRule = AlphaNumericOrWhitespaceValidationRule; - var MediumPasswordValidationRule = (function (_ValidationRule18) { + var MediumPasswordValidationRule = (function (_ValidationRule20) { function MediumPasswordValidationRule(minimumComplexityLevel) { _classCallCheck(this, MediumPasswordValidationRule); - _ValidationRule18.call(this, minimumComplexityLevel ? minimumComplexityLevel : 3, function (newValue, threshold) { + _ValidationRule20.call(this, minimumComplexityLevel ? minimumComplexityLevel : 3, function (newValue, threshold) { if (typeof newValue !== 'string') return false; var strength = 0; @@ -419,7 +599,7 @@ define(['exports', '../validation/utilities', '../validation/validation-locale'] }); } - _inherits(MediumPasswordValidationRule, _ValidationRule18); + _inherits(MediumPasswordValidationRule, _ValidationRule20); return MediumPasswordValidationRule; })(ValidationRule); @@ -440,11 +620,11 @@ define(['exports', '../validation/utilities', '../validation/validation-locale'] exports.StrongPasswordValidationRule = StrongPasswordValidationRule; - var EqualityValidationRuleBase = (function (_ValidationRule19) { + var EqualityValidationRuleBase = (function (_ValidationRule21) { function EqualityValidationRuleBase(otherValue, equality, otherValueLabel) { _classCallCheck(this, EqualityValidationRuleBase); - _ValidationRule19.call(this, { + _ValidationRule21.call(this, { otherValue: otherValue, equality: equality, otherValueLabel: otherValueLabel @@ -455,7 +635,7 @@ define(['exports', '../validation/utilities', '../validation/validation-locale'] }); } - _inherits(EqualityValidationRuleBase, _ValidationRule19); + _inherits(EqualityValidationRuleBase, _ValidationRule21); return EqualityValidationRuleBase; })(ValidationRule); @@ -518,11 +698,11 @@ define(['exports', '../validation/utilities', '../validation/validation-locale'] exports.InEqualityWithOtherLabelValidationRule = InEqualityWithOtherLabelValidationRule; - var InCollectionValidationRule = (function (_ValidationRule20) { + var InCollectionValidationRule = (function (_ValidationRule22) { function InCollectionValidationRule(collection) { _classCallCheck(this, InCollectionValidationRule); - _ValidationRule20.call(this, collection, function (newValue, threshold) { + _ValidationRule22.call(this, collection, function (newValue, threshold) { var collection = _validationUtilities.Utilities.getValue(threshold); for (var i = 0; i < collection.length; i++) { if (newValue === collection[i]) return true; @@ -531,7 +711,7 @@ define(['exports', '../validation/utilities', '../validation/validation-locale'] }); } - _inherits(InCollectionValidationRule, _ValidationRule20); + _inherits(InCollectionValidationRule, _ValidationRule22); return InCollectionValidationRule; })(ValidationRule); diff --git a/dist/commonjs/resources/de-DE.js b/dist/commonjs/resources/de-DE.js index 1a0ef27e..610636a7 100644 --- a/dist/commonjs/resources/de-DE.js +++ b/dist/commonjs/resources/de-DE.js @@ -62,6 +62,9 @@ var data = { NumericValidationRule: function NumericValidationRule(newValue, threshold) { return 'muss eine Nummer sein'; }, + NoSpacesValidationRule: function NoSpacesValidationRule(newValue, threshold) { + return 'darf keine Leerzeichen enthalten'; + }, RegexValidationRule: function RegexValidationRule(newValue, threshold) { return 'ist kein gültiger Wert'; }, @@ -73,6 +76,9 @@ var data = { }, MediumPasswordValidationRule: function MediumPasswordValidationRule(newValue, threshold) { return 'sollte zumindest ' + _Utilities.Utilities.getValue(threshold) + ' der folgenden Gruppen enthalten: Kleinbuchstaben, Großbuchstaben, Zahlen oder Sonderzeichen'; + }, + URLValidationRule: function URLValidationRule(newValue, threshold) { + return 'ist keine gültige URL'; } } }; diff --git a/dist/commonjs/resources/en-US.js b/dist/commonjs/resources/en-US.js index 06fbc343..acb5903f 100644 --- a/dist/commonjs/resources/en-US.js +++ b/dist/commonjs/resources/en-US.js @@ -74,6 +74,9 @@ var data = { NumericValidationRule: function NumericValidationRule(newValue, threshold) { return 'needs to be a number'; }, + NoSpacesValidationRule: function NoSpacesValidationRule(newValue, threshold) { + return 'cannot contain spaces'; + }, RegexValidationRule: function RegexValidationRule(newValue, threshold) { return 'not a valid value'; }, @@ -85,6 +88,9 @@ var data = { }, MediumPasswordValidationRule: function MediumPasswordValidationRule(newValue, threshold) { return 'should contain at least ' + _Utilities.Utilities.getValue(threshold) + ' of the following groups: lowercase letters, uppercase letters, digits or special characters'; + }, + URLValidationRule: function URLValidationRule(newValue, threshold) { + return 'is not a valid URL'; } } }; diff --git a/dist/commonjs/resources/es-MX.js b/dist/commonjs/resources/es-MX.js index a8b1a72d..0be55537 100644 --- a/dist/commonjs/resources/es-MX.js +++ b/dist/commonjs/resources/es-MX.js @@ -74,6 +74,9 @@ var data = { NumericValidationRule: function NumericValidationRule(newValue, threshold) { return 'debe ser un numero'; }, + NoSpacesValidationRule: function NoSpacesValidationRule(newValue, threshold) { + return 'no puede contener espacios'; + }, RegexValidationRule: function RegexValidationRule(newValue, threshold) { return 'no es un valor valido'; }, @@ -85,6 +88,9 @@ var data = { }, MediumPasswordValidationRule: function MediumPasswordValidationRule(newValue, threshold) { return 'debe poseer al menos ' + _Utilities.Utilities.getValue(threshold) + ' de las siguientes características: letras minúsculas, letras mayúsculas, dígitos o caracteres especiales'; + }, + URLValidationRule: function URLValidationRule(newValue, threshold) { + return 'no es una URL válida'; } } }; diff --git a/dist/commonjs/resources/fr-FR.js b/dist/commonjs/resources/fr-FR.js index e2bad2ed..3f57dfb1 100644 --- a/dist/commonjs/resources/fr-FR.js +++ b/dist/commonjs/resources/fr-FR.js @@ -74,6 +74,9 @@ var data = { NumericValidationRule: function NumericValidationRule(newValue, threshold) { return 'doit être une valeur numérique'; }, + NoSpacesValidationRule: function NoSpacesValidationRule(newValue, threshold) { + return 'ne peut pas contenir d\'espaces'; + }, RegexValidationRule: function RegexValidationRule(newValue, threshold) { return 'n\'est pas une valeur valide'; }, @@ -85,6 +88,9 @@ var data = { }, MediumPasswordValidationRule: function MediumPasswordValidationRule(newValue, threshold) { return 'doit contenir au moins ' + _Utilities.Utilities.getValue(threshold) + ' des caractéristiques suivantes : lettres minuscules, lettres majuscules, caractères numériques ou caractères spéciaux'; + }, + URLValidationRule: function URLValidationRule(newValue, threshold) { + return 'est pas un URL valide'; } } }; diff --git a/dist/commonjs/resources/nl-BE.js b/dist/commonjs/resources/nl-BE.js index 988c9910..9c984bb8 100644 --- a/dist/commonjs/resources/nl-BE.js +++ b/dist/commonjs/resources/nl-BE.js @@ -74,6 +74,9 @@ var data = { NumericValidationRule: function NumericValidationRule(newValue, threshold) { return 'moet een getal zijn'; }, + NoSpacesValidationRule: function NoSpacesValidationRule(newValue, threshold) { + return 'mag geen spaties bevatten'; + }, RegexValidationRule: function RegexValidationRule(newValue, threshold) { return 'is geen geldige waarde'; }, @@ -85,6 +88,9 @@ var data = { }, MediumPasswordValidationRule: function MediumPasswordValidationRule(newValue, threshold) { return 'moet op zijn minst ' + _Utilities.Utilities.getValue(threshold) + ' van de volgende groepen bevatten: letters, hoofdletters, cijfers of speciale tekens'; + }, + URLValidationRule: function URLValidationRule(newValue, threshold) { + return 'is geen geldige URL'; } } }; diff --git a/dist/commonjs/resources/nl-NL.js b/dist/commonjs/resources/nl-NL.js index 988c9910..9c984bb8 100644 --- a/dist/commonjs/resources/nl-NL.js +++ b/dist/commonjs/resources/nl-NL.js @@ -74,6 +74,9 @@ var data = { NumericValidationRule: function NumericValidationRule(newValue, threshold) { return 'moet een getal zijn'; }, + NoSpacesValidationRule: function NoSpacesValidationRule(newValue, threshold) { + return 'mag geen spaties bevatten'; + }, RegexValidationRule: function RegexValidationRule(newValue, threshold) { return 'is geen geldige waarde'; }, @@ -85,6 +88,9 @@ var data = { }, MediumPasswordValidationRule: function MediumPasswordValidationRule(newValue, threshold) { return 'moet op zijn minst ' + _Utilities.Utilities.getValue(threshold) + ' van de volgende groepen bevatten: letters, hoofdletters, cijfers of speciale tekens'; + }, + URLValidationRule: function URLValidationRule(newValue, threshold) { + return 'is geen geldige URL'; } } }; diff --git a/dist/commonjs/resources/sv-SE.js b/dist/commonjs/resources/sv-SE.js index 3f424788..abe8f037 100644 --- a/dist/commonjs/resources/sv-SE.js +++ b/dist/commonjs/resources/sv-SE.js @@ -74,6 +74,9 @@ var data = { NumericValidationRule: function NumericValidationRule(newValue, threshold) { return 'måste vara ett nummer'; }, + NoSpacesValidationRule: function NoSpacesValidationRule(newValue, threshold) { + return 'kan inte innehålla mellanslag'; + }, RegexValidationRule: function RegexValidationRule(newValue, threshold) { return 'är inte ett giltigt värde'; }, @@ -85,6 +88,9 @@ var data = { }, MediumPasswordValidationRule: function MediumPasswordValidationRule(newValue, threshold) { return 'ska innehålla minst ' + _Utilities.Utilities.getValue(threshold) + ' av följande grupperingar: gemener, versaler, siffror eller specialtecken'; + }, + URLValidationRule: function URLValidationRule(newValue, threshold) { + return 'är inte en giltig webbadress'; } } }; diff --git a/dist/commonjs/resources/tr-TR.js b/dist/commonjs/resources/tr-TR.js index 5c778077..0a9176f8 100644 --- a/dist/commonjs/resources/tr-TR.js +++ b/dist/commonjs/resources/tr-TR.js @@ -74,6 +74,9 @@ var data = { NumericValidationRule: function NumericValidationRule(newValue, threshold) { return 'sadece sayı girebilirsiniz'; }, + NoSpacesValidationRule: function NoSpacesValidationRule(newValue, threshold) { + return 'boşluk içeremez'; + }, RegexValidationRule: function RegexValidationRule(newValue, threshold) { return 'geçerli bir değer giriniz'; }, @@ -85,6 +88,9 @@ var data = { }, MediumPasswordValidationRule: function MediumPasswordValidationRule(newValue, threshold) { return 'küçük harfler, büyük harfler, sayılar veya işaretlerden en az ' + _Utilities.Utilities.getValue(threshold) + ' değişik tip olmalı'; + }, + URLValidationRule: function URLValidationRule(newValue, threshold) { + return 'Geçerli bir URL değil'; } } }; diff --git a/dist/commonjs/validation/path-observer.js b/dist/commonjs/validation/path-observer.js index a977c5ab..beae20d6 100644 --- a/dist/commonjs/validation/path-observer.js +++ b/dist/commonjs/validation/path-observer.js @@ -75,7 +75,7 @@ var PathObserver = (function () { PathObserver.prototype.observePart = function observePart(part) { if (part !== this.path[this.path.length - 1]) { - this.observerParts(); + this.observeParts(); } }; diff --git a/dist/commonjs/validation/validation-config.js b/dist/commonjs/validation/validation-config.js index d113089a..8306c1af 100644 --- a/dist/commonjs/validation/validation-config.js +++ b/dist/commonjs/validation/validation-config.js @@ -62,7 +62,7 @@ var ValidationConfig = (function () { _this.changedHandlers.set(id, callback); return { v: function () { - changedHandlers['delete'](id); + _this.changedHandlers['delete'](id); } }; })(); diff --git a/dist/commonjs/validation/validation-group-builder.js b/dist/commonjs/validation/validation-group-builder.js index 4b4adba7..99a30198 100644 --- a/dist/commonjs/validation/validation-group-builder.js +++ b/dist/commonjs/validation/validation-group-builder.js @@ -103,6 +103,10 @@ var ValidationGroupBuilder = (function () { return this.passesRule(new AllRules.EmailValidationRule()); }; + ValidationGroupBuilder.prototype.isURL = function isURL() { + return this.passesRule(new AllRules.URLValidationRule()); + }; + ValidationGroupBuilder.prototype.hasMinLength = function hasMinLength(minimumValue) { return this.passesRule(new AllRules.MinimumLengthValidationRule(minimumValue)); }; @@ -119,6 +123,10 @@ var ValidationGroupBuilder = (function () { return this.passesRule(new AllRules.NumericValidationRule()); }; + ValidationGroupBuilder.prototype.containsNoSpaces = function containsNoSpaces() { + return this.passesRule(new AllRules.NoSpacesValidationRule()); + }; + ValidationGroupBuilder.prototype.containsOnlyDigits = function containsOnlyDigits() { return this.passesRule(new AllRules.DigitValidationRule()); }; diff --git a/dist/commonjs/validation/validation-group.js b/dist/commonjs/validation/validation-group.js index 9ce8b88e..c05ed2d0 100644 --- a/dist/commonjs/validation/validation-group.js +++ b/dist/commonjs/validation/validation-group.js @@ -216,6 +216,10 @@ var ValidationGroup = (function () { return this.builder.isEmail(); }; + ValidationGroup.prototype.isURL = function isURL() { + return this.builder.isURL(); + }; + ValidationGroup.prototype.isIn = function isIn(collection) { return this.builder.isIn(collection); }; @@ -236,6 +240,10 @@ var ValidationGroup = (function () { return this.builder.isNumber(); }; + ValidationGroup.prototype.containsNoSpaces = function containsNoSpaces() { + return this.builder.containsNoSpaces(); + }; + ValidationGroup.prototype.containsOnlyDigits = function containsOnlyDigits() { return this.builder.containsOnlyDigits(); }; diff --git a/dist/commonjs/validation/validation-property.js b/dist/commonjs/validation/validation-property.js index d2f9b92a..83ac9d78 100644 --- a/dist/commonjs/validation/validation-property.js +++ b/dist/commonjs/validation/validation-property.js @@ -54,7 +54,7 @@ var ValidationProperty = (function () { } ValidationProperty.prototype.addValidationRule = function addValidationRule(validationRule) { - if (validationRule.validate === undefined) throw new exception('That\'s not a valid validationRule'); + if (validationRule.validate === undefined) throw new Error('That\'s not a valid validationRule'); this.collectionOfValidationRules.addValidationRule(validationRule); this.validateCurrentValue(false); }; diff --git a/dist/commonjs/validation/validation-rules-collection.js b/dist/commonjs/validation/validation-rules-collection.js index 3384ea86..ad987ec3 100644 --- a/dist/commonjs/validation/validation-rules-collection.js +++ b/dist/commonjs/validation/validation-rules-collection.js @@ -93,7 +93,7 @@ var ValidationRulesCollection = (function () { }; ValidationRulesCollection.prototype.addValidationRule = function addValidationRule(validationRule) { - if (validationRule.validate === undefined) throw new exception('That\'s not a valid validationRule'); + if (validationRule.validate === undefined) throw new Error('That\'s not a valid validationRule'); this.validationRules.push(validationRule); }; diff --git a/dist/commonjs/validation/validation-rules.js b/dist/commonjs/validation/validation-rules.js index 94287864..af8f72d0 100644 --- a/dist/commonjs/validation/validation-rules.js +++ b/dist/commonjs/validation/validation-rules.js @@ -75,13 +75,174 @@ var ValidationRule = (function () { exports.ValidationRule = ValidationRule; -var EmailValidationRule = (function (_ValidationRule) { - function EmailValidationRule() { +var URLValidationRule = (function (_ValidationRule) { + function URLValidationRule(threshold) { var _this2 = this; + _classCallCheck(this, URLValidationRule); + + var default_url_options = { + protocols: ['http', 'https', 'ftp'], + require_tld: true, + require_protocol: false, + allow_underscores: true, + allow_trailing_dot: false, + allow_protocol_relative_urls: true + }; + if (threshold === undefined) { + threshold = default_url_options; + } + + _ValidationRule.call(this, threshold, function (newValue, threshold) { + var url = newValue; + if (!url || url.length >= 2083 || /\s/.test(url)) { + return false; + } + if (url.indexOf('mailto:') === 0) { + return false; + } + var protocol, auth, host, hostname, port, port_str, split; + split = url.split('://'); + if (split.length > 1) { + protocol = split.shift(); + if (threshold.protocols.indexOf(protocol) === -1) { + return false; + } + } else if (threshold.require_protocol) { + return false; + } else if (threshold.allow_protocol_relative_urls && url.substr(0, 2) === '//') { + split[0] = url.substr(2); + } + url = split.join('://'); + split = url.split('#'); + url = split.shift(); + + split = url.split('?'); + url = split.shift(); + + split = url.split('/'); + url = split.shift(); + split = url.split('@'); + if (split.length > 1) { + auth = split.shift(); + if (auth.indexOf(':') >= 0 && auth.split(':').length > 2) { + return false; + } + } + hostname = split.join('@'); + split = hostname.split(':'); + host = split.shift(); + if (split.length) { + port_str = split.join(':'); + port = parseInt(port_str, 10); + if (!/^[0-9]+$/.test(port_str) || port <= 0 || port > 65535) { + return false; + } + } + if (!_this2.isIP(host) && !_this2.isFQDN(host, threshold) && host !== 'localhost') { + return false; + } + if (threshold.host_whitelist && threshold.host_whitelist.indexOf(host) === -1) { + return false; + } + if (threshold.host_blacklist && threshold.host_blacklist.indexOf(host) !== -1) { + return false; + } + return true; + }); + this.isIP = function (str, version) { + var ipv4Maybe = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/, + ipv6Block = /^[0-9A-F]{1,4}$/i; + + if (!version) { + return this.isIP(str, 4) || this.isIP(str, 6); + } else if (version === 4) { + if (!ipv4Maybe.test(str)) { + return false; + } + var parts = str.split('.').sort(function (a, b) { + return a - b; + }); + return parts[3] <= 255; + } else if (version === 6) { + var blocks = str.split(':'); + var foundOmissionBlock = false; + + if (blocks.length > 8) return false; + + if (str === '::') { + return true; + } else if (str.substr(0, 2) === '::') { + blocks.shift(); + blocks.shift(); + foundOmissionBlock = true; + } else if (str.substr(str.length - 2) === '::') { + blocks.pop(); + blocks.pop(); + foundOmissionBlock = true; + } + + for (var i = 0; i < blocks.length; ++i) { + if (blocks[i] === '' && i > 0 && i < blocks.length - 1) { + if (foundOmissionBlock) return false; + foundOmissionBlock = true; + } else if (!ipv6Block.test(blocks[i])) { + return false; + } + } + + if (foundOmissionBlock) { + return blocks.length >= 1; + } else { + return blocks.length === 8; + } + } + return false; + }; + this.isFQDN = function (str, options) { + if (options.allow_trailing_dot && str[str.length - 1] === '.') { + str = str.substring(0, str.length - 1); + } + var parts = str.split('.'); + if (options.require_tld) { + var tld = parts.pop(); + if (!parts.length || !/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) { + return false; + } + } + for (var part, i = 0; i < parts.length; i++) { + part = parts[i]; + if (options.allow_underscores) { + if (part.indexOf('__') >= 0) { + return false; + } + part = part.replace(/_/g, ''); + } + if (!/^[a-z\u00a1-\uffff0-9-]+$/i.test(part)) { + return false; + } + if (part[0] === '-' || part[part.length - 1] === '-' || part.indexOf('---') >= 0) { + return false; + } + } + return true; + }; + } + + _inherits(URLValidationRule, _ValidationRule); + + return URLValidationRule; +})(ValidationRule); + +exports.URLValidationRule = URLValidationRule; + +var EmailValidationRule = (function (_ValidationRule2) { + function EmailValidationRule() { + var _this3 = this; + _classCallCheck(this, EmailValidationRule); - _ValidationRule.call(this, null, function (newValue, threshold) { + _ValidationRule2.call(this, null, function (newValue, threshold) { if (/\s/.test(newValue)) { return false; } @@ -89,10 +250,10 @@ var EmailValidationRule = (function (_ValidationRule) { var domain = parts.pop(); var user = parts.join('@'); - if (!_this2.isFQDN(domain)) { + if (!_this3.isFQDN(domain)) { return false; } - return _this2.emailUserUtf8Regex.test(user); + return _this3.emailUserUtf8Regex.test(user); }); this.emailUserUtf8Regex = /^((([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)))$/i; this.isFQDN = function (str) { @@ -114,103 +275,103 @@ var EmailValidationRule = (function (_ValidationRule) { }; } - _inherits(EmailValidationRule, _ValidationRule); + _inherits(EmailValidationRule, _ValidationRule2); return EmailValidationRule; })(ValidationRule); exports.EmailValidationRule = EmailValidationRule; -var MinimumLengthValidationRule = (function (_ValidationRule2) { +var MinimumLengthValidationRule = (function (_ValidationRule3) { function MinimumLengthValidationRule(minimumLength) { _classCallCheck(this, MinimumLengthValidationRule); - _ValidationRule2.call(this, minimumLength, function (newValue, minimumLength) { + _ValidationRule3.call(this, minimumLength, function (newValue, minimumLength) { return newValue.length !== undefined && newValue.length >= minimumLength; }); } - _inherits(MinimumLengthValidationRule, _ValidationRule2); + _inherits(MinimumLengthValidationRule, _ValidationRule3); return MinimumLengthValidationRule; })(ValidationRule); exports.MinimumLengthValidationRule = MinimumLengthValidationRule; -var MaximumLengthValidationRule = (function (_ValidationRule3) { +var MaximumLengthValidationRule = (function (_ValidationRule4) { function MaximumLengthValidationRule(maximumLength) { _classCallCheck(this, MaximumLengthValidationRule); - _ValidationRule3.call(this, maximumLength, function (newValue, maximumLength) { + _ValidationRule4.call(this, maximumLength, function (newValue, maximumLength) { return newValue.length !== undefined && newValue.length <= maximumLength; }); } - _inherits(MaximumLengthValidationRule, _ValidationRule3); + _inherits(MaximumLengthValidationRule, _ValidationRule4); return MaximumLengthValidationRule; })(ValidationRule); exports.MaximumLengthValidationRule = MaximumLengthValidationRule; -var BetweenLengthValidationRule = (function (_ValidationRule4) { +var BetweenLengthValidationRule = (function (_ValidationRule5) { function BetweenLengthValidationRule(minimumLength, maximumLength) { _classCallCheck(this, BetweenLengthValidationRule); - _ValidationRule4.call(this, { minimumLength: minimumLength, maximumLength: maximumLength }, function (newValue, threshold) { + _ValidationRule5.call(this, { minimumLength: minimumLength, maximumLength: maximumLength }, function (newValue, threshold) { return newValue.length !== undefined && newValue.length >= threshold.minimumLength && newValue.length <= threshold.maximumLength; }); } - _inherits(BetweenLengthValidationRule, _ValidationRule4); + _inherits(BetweenLengthValidationRule, _ValidationRule5); return BetweenLengthValidationRule; })(ValidationRule); exports.BetweenLengthValidationRule = BetweenLengthValidationRule; -var CustomFunctionValidationRule = (function (_ValidationRule5) { +var CustomFunctionValidationRule = (function (_ValidationRule6) { function CustomFunctionValidationRule(customFunction, threshold) { _classCallCheck(this, CustomFunctionValidationRule); - _ValidationRule5.call(this, threshold, customFunction); + _ValidationRule6.call(this, threshold, customFunction); } - _inherits(CustomFunctionValidationRule, _ValidationRule5); + _inherits(CustomFunctionValidationRule, _ValidationRule6); return CustomFunctionValidationRule; })(ValidationRule); exports.CustomFunctionValidationRule = CustomFunctionValidationRule; -var NumericValidationRule = (function (_ValidationRule6) { +var NumericValidationRule = (function (_ValidationRule7) { function NumericValidationRule() { _classCallCheck(this, NumericValidationRule); - _ValidationRule6.call(this, null, function (newValue, threshold, locale) { + _ValidationRule7.call(this, null, function (newValue, threshold, locale) { var numericRegex = locale.setting('numericRegex'); var floatValue = parseFloat(newValue); - return !Number.isNaN(parseFloat(floatValue)) && Number.isFinite(floatValue) && numericRegex.test(newValue); + return !Number.isNaN(parseFloat(newValue)) && Number.isFinite(floatValue) && numericRegex.test(newValue); }); } - _inherits(NumericValidationRule, _ValidationRule6); + _inherits(NumericValidationRule, _ValidationRule7); return NumericValidationRule; })(ValidationRule); exports.NumericValidationRule = NumericValidationRule; -var RegexValidationRule = (function (_ValidationRule7) { +var RegexValidationRule = (function (_ValidationRule8) { function RegexValidationRule(regex) { _classCallCheck(this, RegexValidationRule); - _ValidationRule7.call(this, regex, function (newValue, regex) { + _ValidationRule8.call(this, regex, function (newValue, regex) { return regex.test(newValue); }); } - _inherits(RegexValidationRule, _ValidationRule7); + _inherits(RegexValidationRule, _ValidationRule8); return RegexValidationRule; })(ValidationRule); @@ -231,186 +392,205 @@ var ContainsOnlyValidationRule = (function (_RegexValidationRule) { exports.ContainsOnlyValidationRule = ContainsOnlyValidationRule; -var MinimumValueValidationRule = (function (_ValidationRule8) { +var MinimumValueValidationRule = (function (_ValidationRule9) { function MinimumValueValidationRule(minimumValue) { _classCallCheck(this, MinimumValueValidationRule); - _ValidationRule8.call(this, minimumValue, function (newValue, minimumValue) { + _ValidationRule9.call(this, minimumValue, function (newValue, minimumValue) { return _Utilities.Utilities.getValue(minimumValue) < newValue; }); } - _inherits(MinimumValueValidationRule, _ValidationRule8); + _inherits(MinimumValueValidationRule, _ValidationRule9); return MinimumValueValidationRule; })(ValidationRule); exports.MinimumValueValidationRule = MinimumValueValidationRule; -var MinimumInclusiveValueValidationRule = (function (_ValidationRule9) { +var MinimumInclusiveValueValidationRule = (function (_ValidationRule10) { function MinimumInclusiveValueValidationRule(minimumValue) { _classCallCheck(this, MinimumInclusiveValueValidationRule); - _ValidationRule9.call(this, minimumValue, function (newValue, minimumValue) { + _ValidationRule10.call(this, minimumValue, function (newValue, minimumValue) { return _Utilities.Utilities.getValue(minimumValue) <= newValue; }); } - _inherits(MinimumInclusiveValueValidationRule, _ValidationRule9); + _inherits(MinimumInclusiveValueValidationRule, _ValidationRule10); return MinimumInclusiveValueValidationRule; })(ValidationRule); exports.MinimumInclusiveValueValidationRule = MinimumInclusiveValueValidationRule; -var MaximumValueValidationRule = (function (_ValidationRule10) { +var MaximumValueValidationRule = (function (_ValidationRule11) { function MaximumValueValidationRule(maximumValue) { _classCallCheck(this, MaximumValueValidationRule); - _ValidationRule10.call(this, maximumValue, function (newValue, maximumValue) { + _ValidationRule11.call(this, maximumValue, function (newValue, maximumValue) { return newValue < _Utilities.Utilities.getValue(maximumValue); }); } - _inherits(MaximumValueValidationRule, _ValidationRule10); + _inherits(MaximumValueValidationRule, _ValidationRule11); return MaximumValueValidationRule; })(ValidationRule); exports.MaximumValueValidationRule = MaximumValueValidationRule; -var MaximumInclusiveValueValidationRule = (function (_ValidationRule11) { +var MaximumInclusiveValueValidationRule = (function (_ValidationRule12) { function MaximumInclusiveValueValidationRule(maximumValue) { _classCallCheck(this, MaximumInclusiveValueValidationRule); - _ValidationRule11.call(this, maximumValue, function (newValue, maximumValue) { + _ValidationRule12.call(this, maximumValue, function (newValue, maximumValue) { return newValue <= _Utilities.Utilities.getValue(maximumValue); }); } - _inherits(MaximumInclusiveValueValidationRule, _ValidationRule11); + _inherits(MaximumInclusiveValueValidationRule, _ValidationRule12); return MaximumInclusiveValueValidationRule; })(ValidationRule); exports.MaximumInclusiveValueValidationRule = MaximumInclusiveValueValidationRule; -var BetweenValueValidationRule = (function (_ValidationRule12) { +var BetweenValueValidationRule = (function (_ValidationRule13) { function BetweenValueValidationRule(minimumValue, maximumValue) { _classCallCheck(this, BetweenValueValidationRule); - _ValidationRule12.call(this, { minimumValue: minimumValue, maximumValue: maximumValue }, function (newValue, threshold) { + _ValidationRule13.call(this, { minimumValue: minimumValue, maximumValue: maximumValue }, function (newValue, threshold) { return _Utilities.Utilities.getValue(threshold.minimumValue) <= newValue && newValue <= _Utilities.Utilities.getValue(threshold.maximumValue); }); } - _inherits(BetweenValueValidationRule, _ValidationRule12); + _inherits(BetweenValueValidationRule, _ValidationRule13); return BetweenValueValidationRule; })(ValidationRule); exports.BetweenValueValidationRule = BetweenValueValidationRule; -var DigitValidationRule = (function (_ValidationRule13) { +var DigitValidationRule = (function (_ValidationRule14) { function DigitValidationRule() { - var _this3 = this; + var _this4 = this; _classCallCheck(this, DigitValidationRule); - _ValidationRule13.call(this, null, function (newValue, threshold) { - return _this3.digitRegex.test(newValue); + _ValidationRule14.call(this, null, function (newValue, threshold) { + return _this4.digitRegex.test(newValue); }); this.digitRegex = /^\d+$/; } - _inherits(DigitValidationRule, _ValidationRule13); + _inherits(DigitValidationRule, _ValidationRule14); return DigitValidationRule; })(ValidationRule); exports.DigitValidationRule = DigitValidationRule; -var AlphaNumericValidationRule = (function (_ValidationRule14) { +var NoSpacesValidationRule = (function (_ValidationRule15) { + function NoSpacesValidationRule() { + var _this5 = this; + + _classCallCheck(this, NoSpacesValidationRule); + + _ValidationRule15.call(this, null, function (newValue, threshold) { + return _this5.regex.test(newValue); + }); + this.regex = /^\S*$/; + } + + _inherits(NoSpacesValidationRule, _ValidationRule15); + + return NoSpacesValidationRule; +})(ValidationRule); + +exports.NoSpacesValidationRule = NoSpacesValidationRule; + +var AlphaNumericValidationRule = (function (_ValidationRule16) { function AlphaNumericValidationRule() { - var _this4 = this; + var _this6 = this; _classCallCheck(this, AlphaNumericValidationRule); - _ValidationRule14.call(this, null, function (newValue, threshold) { - return _this4.alphaNumericRegex.test(newValue); + _ValidationRule16.call(this, null, function (newValue, threshold) { + return _this6.alphaNumericRegex.test(newValue); }); this.alphaNumericRegex = /^[a-z0-9]+$/i; } - _inherits(AlphaNumericValidationRule, _ValidationRule14); + _inherits(AlphaNumericValidationRule, _ValidationRule16); return AlphaNumericValidationRule; })(ValidationRule); exports.AlphaNumericValidationRule = AlphaNumericValidationRule; -var AlphaValidationRule = (function (_ValidationRule15) { +var AlphaValidationRule = (function (_ValidationRule17) { function AlphaValidationRule() { - var _this5 = this; + var _this7 = this; _classCallCheck(this, AlphaValidationRule); - _ValidationRule15.call(this, null, function (newValue, threshold) { - return _this5.alphaRegex.test(newValue); + _ValidationRule17.call(this, null, function (newValue, threshold) { + return _this7.alphaRegex.test(newValue); }); this.alphaRegex = /^[a-z]+$/i; } - _inherits(AlphaValidationRule, _ValidationRule15); + _inherits(AlphaValidationRule, _ValidationRule17); return AlphaValidationRule; })(ValidationRule); exports.AlphaValidationRule = AlphaValidationRule; -var AlphaOrWhitespaceValidationRule = (function (_ValidationRule16) { +var AlphaOrWhitespaceValidationRule = (function (_ValidationRule18) { function AlphaOrWhitespaceValidationRule() { - var _this6 = this; + var _this8 = this; _classCallCheck(this, AlphaOrWhitespaceValidationRule); - _ValidationRule16.call(this, null, function (newValue, threshold) { - return _this6.alphaNumericRegex.test(newValue); + _ValidationRule18.call(this, null, function (newValue, threshold) { + return _this8.alphaNumericRegex.test(newValue); }); this.alphaNumericRegex = /^[a-z\s]+$/i; } - _inherits(AlphaOrWhitespaceValidationRule, _ValidationRule16); + _inherits(AlphaOrWhitespaceValidationRule, _ValidationRule18); return AlphaOrWhitespaceValidationRule; })(ValidationRule); exports.AlphaOrWhitespaceValidationRule = AlphaOrWhitespaceValidationRule; -var AlphaNumericOrWhitespaceValidationRule = (function (_ValidationRule17) { +var AlphaNumericOrWhitespaceValidationRule = (function (_ValidationRule19) { function AlphaNumericOrWhitespaceValidationRule() { - var _this7 = this; + var _this9 = this; _classCallCheck(this, AlphaNumericOrWhitespaceValidationRule); - _ValidationRule17.call(this, null, function (newValue, threshold) { - return _this7.alphaNumericRegex.test(newValue); + _ValidationRule19.call(this, null, function (newValue, threshold) { + return _this9.alphaNumericRegex.test(newValue); }); this.alphaNumericRegex = /^[a-z0-9\s]+$/i; } - _inherits(AlphaNumericOrWhitespaceValidationRule, _ValidationRule17); + _inherits(AlphaNumericOrWhitespaceValidationRule, _ValidationRule19); return AlphaNumericOrWhitespaceValidationRule; })(ValidationRule); exports.AlphaNumericOrWhitespaceValidationRule = AlphaNumericOrWhitespaceValidationRule; -var MediumPasswordValidationRule = (function (_ValidationRule18) { +var MediumPasswordValidationRule = (function (_ValidationRule20) { function MediumPasswordValidationRule(minimumComplexityLevel) { _classCallCheck(this, MediumPasswordValidationRule); - _ValidationRule18.call(this, minimumComplexityLevel ? minimumComplexityLevel : 3, function (newValue, threshold) { + _ValidationRule20.call(this, minimumComplexityLevel ? minimumComplexityLevel : 3, function (newValue, threshold) { if (typeof newValue !== 'string') return false; var strength = 0; @@ -422,7 +602,7 @@ var MediumPasswordValidationRule = (function (_ValidationRule18) { }); } - _inherits(MediumPasswordValidationRule, _ValidationRule18); + _inherits(MediumPasswordValidationRule, _ValidationRule20); return MediumPasswordValidationRule; })(ValidationRule); @@ -443,11 +623,11 @@ var StrongPasswordValidationRule = (function (_MediumPasswordValidationRule) { exports.StrongPasswordValidationRule = StrongPasswordValidationRule; -var EqualityValidationRuleBase = (function (_ValidationRule19) { +var EqualityValidationRuleBase = (function (_ValidationRule21) { function EqualityValidationRuleBase(otherValue, equality, otherValueLabel) { _classCallCheck(this, EqualityValidationRuleBase); - _ValidationRule19.call(this, { + _ValidationRule21.call(this, { otherValue: otherValue, equality: equality, otherValueLabel: otherValueLabel @@ -458,7 +638,7 @@ var EqualityValidationRuleBase = (function (_ValidationRule19) { }); } - _inherits(EqualityValidationRuleBase, _ValidationRule19); + _inherits(EqualityValidationRuleBase, _ValidationRule21); return EqualityValidationRuleBase; })(ValidationRule); @@ -521,11 +701,11 @@ var InEqualityWithOtherLabelValidationRule = (function (_EqualityValidationRuleB exports.InEqualityWithOtherLabelValidationRule = InEqualityWithOtherLabelValidationRule; -var InCollectionValidationRule = (function (_ValidationRule20) { +var InCollectionValidationRule = (function (_ValidationRule22) { function InCollectionValidationRule(collection) { _classCallCheck(this, InCollectionValidationRule); - _ValidationRule20.call(this, collection, function (newValue, threshold) { + _ValidationRule22.call(this, collection, function (newValue, threshold) { var collection = _Utilities.Utilities.getValue(threshold); for (var i = 0; i < collection.length; i++) { if (newValue === collection[i]) return true; @@ -534,7 +714,7 @@ var InCollectionValidationRule = (function (_ValidationRule20) { }); } - _inherits(InCollectionValidationRule, _ValidationRule20); + _inherits(InCollectionValidationRule, _ValidationRule22); return InCollectionValidationRule; })(ValidationRule); diff --git a/dist/es6/resources/de-DE.js b/dist/es6/resources/de-DE.js index 62b93ea2..e2876b9e 100644 --- a/dist/es6/resources/de-DE.js +++ b/dist/es6/resources/de-DE.js @@ -58,6 +58,9 @@ export let data = { 'NumericValidationRule': (newValue, threshold) => { return `muss eine Nummer sein`; }, + 'NoSpacesValidationRule' : (newValue, threshold) => { + return `darf keine Leerzeichen enthalten`; + }, 'RegexValidationRule': (newValue, threshold) => { return `ist kein gültiger Wert`; }, @@ -69,6 +72,9 @@ export let data = { }, 'MediumPasswordValidationRule' : (newValue, threshold) => { return `sollte zumindest ${Utilities.getValue(threshold)} der folgenden Gruppen enthalten: Kleinbuchstaben, Großbuchstaben, Zahlen oder Sonderzeichen`; + }, + 'URLValidationRule' : (newValue, threshold) =>{ + return `ist keine gültige URL`; } } }; diff --git a/dist/es6/resources/en-US.js b/dist/es6/resources/en-US.js index 7bf75798..f0696033 100644 --- a/dist/es6/resources/en-US.js +++ b/dist/es6/resources/en-US.js @@ -70,6 +70,9 @@ export let data = { 'NumericValidationRule': (newValue, threshold) => { return `needs to be a number`; }, + 'NoSpacesValidationRule' : (newValue, threshold) => { + return `cannot contain spaces`; + }, 'RegexValidationRule': (newValue, threshold) => { return `not a valid value`; }, @@ -81,6 +84,9 @@ export let data = { }, 'MediumPasswordValidationRule' : (newValue, threshold) => { return `should contain at least ${Utilities.getValue(threshold)} of the following groups: lowercase letters, uppercase letters, digits or special characters`; + }, + 'URLValidationRule' : (newValue, threshold) =>{ + return `is not a valid URL` } } }; diff --git a/dist/es6/resources/es-MX.js b/dist/es6/resources/es-MX.js index 6d8b042e..b48db39d 100644 --- a/dist/es6/resources/es-MX.js +++ b/dist/es6/resources/es-MX.js @@ -1,86 +1,92 @@ import {Utilities} from '../validation/utilities'; export let data = { - settings: { - 'numericRegex': /^-?(?:\d+)(?:\,\d+)?$/ - }, - messages:{ - 'isRequired': 'es obligatorio', - 'onValidateCallback' : 'no es un valor valido', - 'AlphaNumericOrWhitespaceValidationRule': (newValue, threshold) => { - return `solo puede contener caracteres alfanuméricos y espacios`; - }, - 'AlphaNumericValidationRule': (newValue, threshold) => { - return `solo puede contener caracteres alfanuméricos`; - }, - 'AlphaValidationRule' : (newValue, threshold) => { - return `solo puede contener letras`; - }, - 'AlphaOrWhitespaceValidationRule' : (newValue, threshold) => { - return `solo puede contener letras y espacios`; - }, - 'BetweenLengthValidationRule': (newValue, threshold) => { - return `debe ser entre ${Utilities.getValue(threshold.minimumLength)} y ${Utilities.getValue(threshold.maximumLength)} letras de largo`; - }, - 'BetweenValueValidationRule': (newValue, threshold) => { - return `debe tener un valor entre ${Utilities.getValue(threshold.minimumValue)} y ${Utilities.getValue(threshold.maximumValue)}`; - }, - 'CustomFunctionValidationRule': (newValue, threshold) => { - return `es un valor invalido` - }, - 'DigitValidationRule': (newValue, threshold) => { - return `solo puede contener numeros`; - }, - 'EmailValidationRule': (newValue, threshold) => { - return `no es un correo electrónico valido`; - }, - 'EqualityValidationRule': (newValue, threshold) => { - return `debe ser ${Utilities.getValue(threshold.otherValue)}`; - }, - 'InEqualityValidationRule' : (newValue, threshold) => { - return `no puede ser ${Utilities.getValue(threshold.otherValue)}`; - }, - 'EqualityWithOtherLabelValidationRule': (newValue, threshold) => { - return `no es igual a ${Utilities.getValue(threshold.otherValueLabel)}`; - }, - 'InEqualityWithOtherLabelValidationRule' : (newValue, threshold) => { - return `no puede ser igual a ${Utilities.getValue(threshold.otherValueLabel)}`; - }, - 'InCollectionValidationRule': (newValue, threshold) => { - return `no es un valor valido`; - }, - 'MinimumInclusiveValueValidationRule' : (newValue, threshold) => { - return `debe ser ${Utilities.getValue(threshold)} o mayor`; - }, - 'MinimumLengthValidationRule': (newValue, threshold) => { - return `debe ser almenos de ${Utilities.getValue(threshold)} caracteres`; - }, - 'MinimumValueValidationRule': (newValue, threshold) => { - return `debe ser ${Utilities.getValue(threshold)} o superior`; - }, - 'MaximumInclusiveValueValidationRule' : (newValue, threshold) => { - return `debe ser ${Utilities.getValue(threshold)} o menos`; - }, - 'MaximumLengthValidationRule': (newValue, threshold) => { - return `no puede medir más de ${Utilities.getValue(threshold)} caracteres`; - }, - 'MaximumValueValidationRule': (newValue, threshold) => { - return `debe ser menor a ${Utilities.getValue(threshold)}`; - }, - 'NumericValidationRule': (newValue, threshold) => { - return `debe ser un numero`; - }, - 'RegexValidationRule': (newValue, threshold) => { - return `no es un valor valido`; - }, - 'ContainsOnlyValidationRule': (newValue, threshold) => { - return `no es un valor valido`; - }, - 'StrongPasswordValidationRule': (newValue, threshold) => { - return `debe contener una combinación de letras minúsculas, mayúsculas, dígitos y caracteres especiales`; - }, - 'MediumPasswordValidationRule' : (newValue, threshold) => { - return `debe poseer al menos ${Utilities.getValue(threshold)} de las siguientes características: letras minúsculas, letras mayúsculas, dígitos o caracteres especiales`; - } + settings: { + 'numericRegex': /^-?(?:\d+)(?:\,\d+)?$/ + }, + messages:{ + 'isRequired': 'es obligatorio', + 'onValidateCallback' : 'no es un valor valido', + 'AlphaNumericOrWhitespaceValidationRule': (newValue, threshold) => { + return `solo puede contener caracteres alfanuméricos y espacios`; + }, + 'AlphaNumericValidationRule': (newValue, threshold) => { + return `solo puede contener caracteres alfanuméricos`; + }, + 'AlphaValidationRule' : (newValue, threshold) => { + return `solo puede contener letras`; + }, + 'AlphaOrWhitespaceValidationRule' : (newValue, threshold) => { + return `solo puede contener letras y espacios`; + }, + 'BetweenLengthValidationRule': (newValue, threshold) => { + return `debe ser entre ${Utilities.getValue(threshold.minimumLength)} y ${Utilities.getValue(threshold.maximumLength)} letras de largo`; + }, + 'BetweenValueValidationRule': (newValue, threshold) => { + return `debe tener un valor entre ${Utilities.getValue(threshold.minimumValue)} y ${Utilities.getValue(threshold.maximumValue)}`; + }, + 'CustomFunctionValidationRule': (newValue, threshold) => { + return `es un valor invalido` + }, + 'DigitValidationRule': (newValue, threshold) => { + return `solo puede contener numeros`; + }, + 'EmailValidationRule': (newValue, threshold) => { + return `no es un correo electrónico valido`; + }, + 'EqualityValidationRule': (newValue, threshold) => { + return `debe ser ${Utilities.getValue(threshold.otherValue)}`; + }, + 'InEqualityValidationRule' : (newValue, threshold) => { + return `no puede ser ${Utilities.getValue(threshold.otherValue)}`; + }, + 'EqualityWithOtherLabelValidationRule': (newValue, threshold) => { + return `no es igual a ${Utilities.getValue(threshold.otherValueLabel)}`; + }, + 'InEqualityWithOtherLabelValidationRule' : (newValue, threshold) => { + return `no puede ser igual a ${Utilities.getValue(threshold.otherValueLabel)}`; + }, + 'InCollectionValidationRule': (newValue, threshold) => { + return `no es un valor valido`; + }, + 'MinimumInclusiveValueValidationRule' : (newValue, threshold) => { + return `debe ser ${Utilities.getValue(threshold)} o mayor`; + }, + 'MinimumLengthValidationRule': (newValue, threshold) => { + return `debe ser almenos de ${Utilities.getValue(threshold)} caracteres`; + }, + 'MinimumValueValidationRule': (newValue, threshold) => { + return `debe ser ${Utilities.getValue(threshold)} o superior`; + }, + 'MaximumInclusiveValueValidationRule' : (newValue, threshold) => { + return `debe ser ${Utilities.getValue(threshold)} o menos`; + }, + 'MaximumLengthValidationRule': (newValue, threshold) => { + return `no puede medir más de ${Utilities.getValue(threshold)} caracteres`; + }, + 'MaximumValueValidationRule': (newValue, threshold) => { + return `debe ser menor a ${Utilities.getValue(threshold)}`; + }, + 'NumericValidationRule': (newValue, threshold) => { + return `debe ser un numero`; + }, + 'NoSpacesValidationRule' : (newValue, threshold) => { + return `no puede contener espacios`; + }, + 'RegexValidationRule': (newValue, threshold) => { + return `no es un valor valido`; + }, + 'ContainsOnlyValidationRule': (newValue, threshold) => { + return `no es un valor valido`; + }, + 'StrongPasswordValidationRule': (newValue, threshold) => { + return `debe contener una combinación de letras minúsculas, mayúsculas, dígitos y caracteres especiales`; + }, + 'MediumPasswordValidationRule' : (newValue, threshold) => { + return `debe poseer al menos ${Utilities.getValue(threshold)} de las siguientes características: letras minúsculas, letras mayúsculas, dígitos o caracteres especiales`; + }, + 'URLValidationRule' : (newValue, threshold) =>{ + return `no es una URL válida` } - }; \ No newline at end of file + } +}; diff --git a/dist/es6/resources/fr-FR.js b/dist/es6/resources/fr-FR.js index f6b8d226..800e5ea1 100644 --- a/dist/es6/resources/fr-FR.js +++ b/dist/es6/resources/fr-FR.js @@ -70,6 +70,9 @@ export let data = { 'NumericValidationRule': (newValue, threshold) => { return `doit être une valeur numérique`; }, + 'NoSpacesValidationRule' : (newValue, threshold) => { + return `ne peut pas contenir d'espaces`; + }, 'RegexValidationRule': (newValue, threshold) => { return `n'est pas une valeur valide`; }, @@ -81,6 +84,9 @@ export let data = { }, 'MediumPasswordValidationRule' : (newValue, threshold) => { return `doit contenir au moins ${Utilities.getValue(threshold)} des caractéristiques suivantes : lettres minuscules, lettres majuscules, caractères numériques ou caractères spéciaux`; + }, + 'URLValidationRule' : (newValue, threshold) =>{ + return `est pas un URL valide`; } } }; diff --git a/dist/es6/resources/nl-BE.js b/dist/es6/resources/nl-BE.js index b400ad4e..08333ca7 100644 --- a/dist/es6/resources/nl-BE.js +++ b/dist/es6/resources/nl-BE.js @@ -70,6 +70,9 @@ export let data = { 'NumericValidationRule': (newValue, threshold) => { return `moet een getal zijn`; }, + 'NoSpacesValidationRule' : (newValue, threshold) => { + return `mag geen spaties bevatten`; + }, 'RegexValidationRule': (newValue, threshold) => { return `is geen geldige waarde`; }, @@ -81,6 +84,9 @@ export let data = { }, 'MediumPasswordValidationRule' : (newValue, threshold) => { return `moet op zijn minst ${Utilities.getValue(threshold)} van de volgende groepen bevatten: letters, hoofdletters, cijfers of speciale tekens`; + }, + 'URLValidationRule' : (newValue, threshold) =>{ + return `is geen geldige URL` } } }; diff --git a/dist/es6/resources/nl-NL.js b/dist/es6/resources/nl-NL.js index d860674a..04e77d6a 100644 --- a/dist/es6/resources/nl-NL.js +++ b/dist/es6/resources/nl-NL.js @@ -70,6 +70,9 @@ export let data = { 'NumericValidationRule': (newValue, threshold) => { return `moet een getal zijn`; }, + 'NoSpacesValidationRule' : (newValue, threshold) => { + return `mag geen spaties bevatten`; + }, 'RegexValidationRule': (newValue, threshold) => { return `is geen geldige waarde`; }, @@ -81,6 +84,9 @@ export let data = { }, 'MediumPasswordValidationRule' : (newValue, threshold) => { return `moet op zijn minst ${Utilities.getValue(threshold)} van de volgende groepen bevatten: letters, hoofdletters, cijfers of speciale tekens`; + }, + 'URLValidationRule' : (newValue, threshold) =>{ + return `is geen geldige URL` } } }; diff --git a/dist/es6/resources/sv-SE.js b/dist/es6/resources/sv-SE.js index 50415f4b..48704941 100644 --- a/dist/es6/resources/sv-SE.js +++ b/dist/es6/resources/sv-SE.js @@ -70,6 +70,9 @@ export let data = { 'NumericValidationRule': (newValue, threshold) => { return `måste vara ett nummer`; }, + 'NoSpacesValidationRule' : (newValue, threshold) => { + return `kan inte innehålla mellanslag`; + }, 'RegexValidationRule': (newValue, threshold) => { return `är inte ett giltigt värde`; }, @@ -81,6 +84,9 @@ export let data = { }, 'MediumPasswordValidationRule' : (newValue, threshold) => { return `ska innehålla minst ${Utilities.getValue(threshold)} av följande grupperingar: gemener, versaler, siffror eller specialtecken`; + }, + 'URLValidationRule' : (newValue, threshold) =>{ + return `är inte en giltig webbadress` } } }; diff --git a/dist/es6/resources/tr-TR.js b/dist/es6/resources/tr-TR.js index 6b3b3f8f..ff03bbde 100644 --- a/dist/es6/resources/tr-TR.js +++ b/dist/es6/resources/tr-TR.js @@ -70,6 +70,9 @@ export let data = { 'NumericValidationRule': (newValue, threshold) => { return `sadece sayı girebilirsiniz`; }, + 'NoSpacesValidationRule' : (newValue, threshold) => { + return `boşluk içeremez`; + }, 'RegexValidationRule': (newValue, threshold) => { return `geçerli bir değer giriniz`; }, @@ -81,6 +84,9 @@ export let data = { }, 'MediumPasswordValidationRule' : (newValue, threshold) => { return `küçük harfler, büyük harfler, sayılar veya işaretlerden en az ${Utilities.getValue(threshold)} değişik tip olmalı`; + }, + 'URLValidationRule' : (newValue, threshold) =>{ + return `Geçerli bir URL değil` } } }; diff --git a/dist/es6/validation/path-observer.js b/dist/es6/validation/path-observer.js index b6f43a19..140384f2 100644 --- a/dist/es6/validation/path-observer.js +++ b/dist/es6/validation/path-observer.js @@ -69,7 +69,7 @@ export class PathObserver { observePart(part) { if (part !== this.path[this.path.length - 1]) { - this.observerParts(); + this.observeParts(); } } diff --git a/dist/es6/validation/validate-custom-attribute.js b/dist/es6/validation/validate-custom-attribute.js index 2d4ab111..f3361700 100644 --- a/dist/es6/validation/validate-custom-attribute.js +++ b/dist/es6/validation/validate-custom-attribute.js @@ -1,7 +1,5 @@ import {inject} from 'aurelia-dependency-injection'; import {customAttribute} from 'aurelia-templating'; -import {Behavior} from 'aurelia-templating'; - @customAttribute('validate') @inject(Element) diff --git a/dist/es6/validation/validation-config.js b/dist/es6/validation/validation-config.js index 1f92d537..fd641b67 100644 --- a/dist/es6/validation/validation-config.js +++ b/dist/es6/validation/validation-config.js @@ -49,7 +49,7 @@ export class ValidationConfig { let id = ++ValidationConfig.uniqueListenerId; this.changedHandlers.set(id, callback); return () => { - changedHandlers.delete(id); + this.changedHandlers.delete(id); }; } } diff --git a/dist/es6/validation/validation-group-builder.js b/dist/es6/validation/validation-group-builder.js index c9eaa4d0..8ef9fee9 100644 --- a/dist/es6/validation/validation-group-builder.js +++ b/dist/es6/validation/validation-group-builder.js @@ -85,6 +85,10 @@ export class ValidationGroupBuilder { return this.passesRule(new AllRules.EmailValidationRule()); } + isURL(){ + return this.passesRule(new AllRules.URLValidationRule()); + } + hasMinLength(minimumValue) { return this.passesRule(new AllRules.MinimumLengthValidationRule(minimumValue)); } @@ -101,6 +105,10 @@ export class ValidationGroupBuilder { return this.passesRule(new AllRules.NumericValidationRule()); } + containsNoSpaces(){ + return this.passesRule(new AllRules.NoSpacesValidationRule()); + } + containsOnlyDigits() { return this.passesRule(new AllRules.DigitValidationRule()); } diff --git a/dist/es6/validation/validation-group.js b/dist/es6/validation/validation-group.js index 25348623..1e52c773 100644 --- a/dist/es6/validation/validation-group.js +++ b/dist/es6/validation/validation-group.js @@ -268,6 +268,13 @@ export class ValidationGroup { isEmail() { return this.builder.isEmail(); } + /** + * Adds a validation rule that checks a value for being a valid URL + * @returns {ValidationGroup} returns this ValidationGroup, to enable fluent API + */ + isURL(){ + return this.builder.isURL(); + } /** * Adds a validation rule that checks a value for being equal to at least one other value in a particular collection @@ -313,6 +320,14 @@ export class ValidationGroup { isNumber() { return this.builder.isNumber(); } + /** + * Adds a validation rule that checks a value for containing not a single whitespace + * @returns {ValidationGroup} returns this ValidationGroup, to enable fluent API + */ + containsNoSpaces() { + return this.builder.containsNoSpaces(); + } + /** * Adds a validation rule that checks a value for being strictly numeric, this excludes formatted numbers like '-3,600.25' diff --git a/dist/es6/validation/validation-property.js b/dist/es6/validation/validation-property.js index 2ae86d7d..cbf4300c 100644 --- a/dist/es6/validation/validation-property.js +++ b/dist/es6/validation/validation-property.js @@ -41,7 +41,7 @@ export class ValidationProperty { addValidationRule(validationRule) { if (validationRule.validate === undefined) //Can ES6 check on base class?? - throw new exception("That's not a valid validationRule"); + throw new Error("That's not a valid validationRule"); this.collectionOfValidationRules.addValidationRule(validationRule); this.validateCurrentValue(false); } diff --git a/dist/es6/validation/validation-rules-collection.js b/dist/es6/validation/validation-rules-collection.js index c11268b0..85a9bcd6 100644 --- a/dist/es6/validation/validation-rules-collection.js +++ b/dist/es6/validation/validation-rules-collection.js @@ -96,7 +96,7 @@ export class ValidationRulesCollection { addValidationRule(validationRule) { if (validationRule.validate === undefined) //Can ES6 check on base class?? - throw new exception("That's not a valid validationRule"); + throw new Error("That's not a valid validationRule"); this.validationRules.push(validationRule); } diff --git a/dist/es6/validation/validation-rules.js b/dist/es6/validation/validation-rules.js index 93015f13..3358f83f 100644 --- a/dist/es6/validation/validation-rules.js +++ b/dist/es6/validation/validation-rules.js @@ -74,6 +74,175 @@ export class ValidationRule { } } +export class URLValidationRule extends ValidationRule{ + //https://github.com/chriso/validator.js/blob/master/LICENSE + constructor(threshold) { + var default_url_options = { + protocols: [ 'http', 'https', 'ftp' ] + , require_tld: true + , require_protocol: false + , allow_underscores: true + , allow_trailing_dot: false + , allow_protocol_relative_urls: true + }; + if(threshold === undefined) + { + threshold = default_url_options; + } + + super( + threshold, + (newValue, threshold) => + { + let url = newValue; + if (!url || url.length >= 2083 || /\s/.test(url)) { + return false; + } + if (url.indexOf('mailto:') === 0) { + return false; + } + var protocol, auth, host, hostname, port, + port_str, split; + split = url.split('://'); + if (split.length > 1) { + protocol = split.shift(); + if (threshold.protocols.indexOf(protocol) === -1) { + return false; + } + } else if (threshold.require_protocol) { + return false; + } else if (threshold.allow_protocol_relative_urls && url.substr(0, 2) === '//') { + split[0] = url.substr(2); + } + url = split.join('://'); + split = url.split('#'); + url = split.shift(); + + split = url.split('?'); + url = split.shift(); + + split = url.split('/'); + url = split.shift(); + split = url.split('@'); + if (split.length > 1) { + auth = split.shift(); + if (auth.indexOf(':') >= 0 && auth.split(':').length > 2) { + return false; + } + } + hostname = split.join('@'); + split = hostname.split(':'); + host = split.shift(); + if (split.length) { + port_str = split.join(':'); + port = parseInt(port_str, 10); + if (!/^[0-9]+$/.test(port_str) || port <= 0 || port > 65535) { + return false; + } + } + if (!this.isIP(host) && !this.isFQDN(host, threshold) && + host !== 'localhost') { + return false; + } + if (threshold.host_whitelist && + threshold.host_whitelist.indexOf(host) === -1) { + return false; + } + if (threshold.host_blacklist && + threshold.host_blacklist.indexOf(host) !== -1) { + return false; + } + return true; + } + ); + this.isIP = function (str, version) { + var ipv4Maybe = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/ + , ipv6Block = /^[0-9A-F]{1,4}$/i; + + if (!version) { + return this.isIP(str, 4) || this.isIP(str, 6); + } else if (version === 4) { + if (!ipv4Maybe.test(str)) { + return false; + } + var parts = str.split('.').sort(function (a, b) { + return a - b; + }); + return parts[3] <= 255; + } else if (version === 6) { + var blocks = str.split(':'); + var foundOmissionBlock = false; // marker to indicate :: + + if (blocks.length > 8) + return false; + + // initial or final :: + if (str === '::') { + return true; + } else if (str.substr(0, 2) === '::') { + blocks.shift(); + blocks.shift(); + foundOmissionBlock = true; + } else if (str.substr(str.length - 2) === '::') { + blocks.pop(); + blocks.pop(); + foundOmissionBlock = true; + } + + for (var i = 0; i < blocks.length; ++i) { + // test for a :: which can not be at the string start/end + // since those cases have been handled above + if (blocks[i] === '' && i > 0 && i < blocks.length -1) { + if (foundOmissionBlock) + return false; // multiple :: in address + foundOmissionBlock = true; + } else if (!ipv6Block.test(blocks[i])) { + return false; + } + } + + if (foundOmissionBlock) { + return blocks.length >= 1; + } else { + return blocks.length === 8; + } + } + return false; + }; + this.isFQDN = function (str, options) { + /* Remove the optional trailing dot before checking validity */ + if (options.allow_trailing_dot && str[str.length - 1] === '.') { + str = str.substring(0, str.length - 1); + } + var parts = str.split('.'); + if (options.require_tld) { + var tld = parts.pop(); + if (!parts.length || !/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) { + return false; + } + } + for (var part, i = 0; i < parts.length; i++) { + part = parts[i]; + if (options.allow_underscores) { + if (part.indexOf('__') >= 0) { + return false; + } + part = part.replace(/_/g, ''); + } + if (!/^[a-z\u00a1-\uffff0-9-]+$/i.test(part)) { + return false; + } + if (part[0] === '-' || part[part.length - 1] === '-' || + part.indexOf('---') >= 0) { + return false; + } + } + return true; + }; + } + +} + export class EmailValidationRule extends ValidationRule { //https://github.com/chriso/validator.js/blob/master/LICENSE constructor() { @@ -166,7 +335,7 @@ export class NumericValidationRule extends ValidationRule { (newValue, threshold, locale) => { var numericRegex = locale.setting('numericRegex'); var floatValue = parseFloat(newValue); - return !Number.isNaN(parseFloat(floatValue)) + return !Number.isNaN(parseFloat(newValue)) && Number.isFinite(floatValue) && numericRegex.test(newValue); } @@ -258,6 +427,18 @@ export class DigitValidationRule extends ValidationRule { } } +export class NoSpacesValidationRule extends ValidationRule{ + constructor() { + super( + null, + (newValue, threshold) => { + return this.regex.test(newValue); + } + ); + this.regex =/^\S*$/; + } +} + export class AlphaNumericValidationRule extends ValidationRule { constructor() { super( diff --git a/dist/system/resources/de-DE.js b/dist/system/resources/de-DE.js index bcbf7045..4cdcd2ba 100644 --- a/dist/system/resources/de-DE.js +++ b/dist/system/resources/de-DE.js @@ -65,6 +65,9 @@ System.register(['../validation/utilities'], function (_export) { NumericValidationRule: function NumericValidationRule(newValue, threshold) { return 'muss eine Nummer sein'; }, + NoSpacesValidationRule: function NoSpacesValidationRule(newValue, threshold) { + return 'darf keine Leerzeichen enthalten'; + }, RegexValidationRule: function RegexValidationRule(newValue, threshold) { return 'ist kein gültiger Wert'; }, @@ -76,6 +79,9 @@ System.register(['../validation/utilities'], function (_export) { }, MediumPasswordValidationRule: function MediumPasswordValidationRule(newValue, threshold) { return 'sollte zumindest ' + Utilities.getValue(threshold) + ' der folgenden Gruppen enthalten: Kleinbuchstaben, Großbuchstaben, Zahlen oder Sonderzeichen'; + }, + URLValidationRule: function URLValidationRule(newValue, threshold) { + return 'ist keine gültige URL'; } } }; diff --git a/dist/system/resources/en-US.js b/dist/system/resources/en-US.js index ebfe4668..460eec44 100644 --- a/dist/system/resources/en-US.js +++ b/dist/system/resources/en-US.js @@ -77,6 +77,9 @@ System.register(['../validation/utilities'], function (_export) { NumericValidationRule: function NumericValidationRule(newValue, threshold) { return 'needs to be a number'; }, + NoSpacesValidationRule: function NoSpacesValidationRule(newValue, threshold) { + return 'cannot contain spaces'; + }, RegexValidationRule: function RegexValidationRule(newValue, threshold) { return 'not a valid value'; }, @@ -88,6 +91,9 @@ System.register(['../validation/utilities'], function (_export) { }, MediumPasswordValidationRule: function MediumPasswordValidationRule(newValue, threshold) { return 'should contain at least ' + Utilities.getValue(threshold) + ' of the following groups: lowercase letters, uppercase letters, digits or special characters'; + }, + URLValidationRule: function URLValidationRule(newValue, threshold) { + return 'is not a valid URL'; } } }; diff --git a/dist/system/resources/es-MX.js b/dist/system/resources/es-MX.js index cd3e3e26..da0bf8b5 100644 --- a/dist/system/resources/es-MX.js +++ b/dist/system/resources/es-MX.js @@ -77,6 +77,9 @@ System.register(['../validation/utilities'], function (_export) { NumericValidationRule: function NumericValidationRule(newValue, threshold) { return 'debe ser un numero'; }, + NoSpacesValidationRule: function NoSpacesValidationRule(newValue, threshold) { + return 'no puede contener espacios'; + }, RegexValidationRule: function RegexValidationRule(newValue, threshold) { return 'no es un valor valido'; }, @@ -88,6 +91,9 @@ System.register(['../validation/utilities'], function (_export) { }, MediumPasswordValidationRule: function MediumPasswordValidationRule(newValue, threshold) { return 'debe poseer al menos ' + Utilities.getValue(threshold) + ' de las siguientes características: letras minúsculas, letras mayúsculas, dígitos o caracteres especiales'; + }, + URLValidationRule: function URLValidationRule(newValue, threshold) { + return 'no es una URL válida'; } } }; diff --git a/dist/system/resources/fr-FR.js b/dist/system/resources/fr-FR.js index 9529f030..c59d60b5 100644 --- a/dist/system/resources/fr-FR.js +++ b/dist/system/resources/fr-FR.js @@ -77,6 +77,9 @@ System.register(['../validation/utilities'], function (_export) { NumericValidationRule: function NumericValidationRule(newValue, threshold) { return 'doit être une valeur numérique'; }, + NoSpacesValidationRule: function NoSpacesValidationRule(newValue, threshold) { + return 'ne peut pas contenir d\'espaces'; + }, RegexValidationRule: function RegexValidationRule(newValue, threshold) { return 'n\'est pas une valeur valide'; }, @@ -88,6 +91,9 @@ System.register(['../validation/utilities'], function (_export) { }, MediumPasswordValidationRule: function MediumPasswordValidationRule(newValue, threshold) { return 'doit contenir au moins ' + Utilities.getValue(threshold) + ' des caractéristiques suivantes : lettres minuscules, lettres majuscules, caractères numériques ou caractères spéciaux'; + }, + URLValidationRule: function URLValidationRule(newValue, threshold) { + return 'est pas un URL valide'; } } }; diff --git a/dist/system/resources/nl-BE.js b/dist/system/resources/nl-BE.js index ed284872..9e5c3d49 100644 --- a/dist/system/resources/nl-BE.js +++ b/dist/system/resources/nl-BE.js @@ -77,6 +77,9 @@ System.register(['../validation/utilities'], function (_export) { NumericValidationRule: function NumericValidationRule(newValue, threshold) { return 'moet een getal zijn'; }, + NoSpacesValidationRule: function NoSpacesValidationRule(newValue, threshold) { + return 'mag geen spaties bevatten'; + }, RegexValidationRule: function RegexValidationRule(newValue, threshold) { return 'is geen geldige waarde'; }, @@ -88,6 +91,9 @@ System.register(['../validation/utilities'], function (_export) { }, MediumPasswordValidationRule: function MediumPasswordValidationRule(newValue, threshold) { return 'moet op zijn minst ' + Utilities.getValue(threshold) + ' van de volgende groepen bevatten: letters, hoofdletters, cijfers of speciale tekens'; + }, + URLValidationRule: function URLValidationRule(newValue, threshold) { + return 'is geen geldige URL'; } } }; diff --git a/dist/system/resources/nl-NL.js b/dist/system/resources/nl-NL.js index ed284872..9e5c3d49 100644 --- a/dist/system/resources/nl-NL.js +++ b/dist/system/resources/nl-NL.js @@ -77,6 +77,9 @@ System.register(['../validation/utilities'], function (_export) { NumericValidationRule: function NumericValidationRule(newValue, threshold) { return 'moet een getal zijn'; }, + NoSpacesValidationRule: function NoSpacesValidationRule(newValue, threshold) { + return 'mag geen spaties bevatten'; + }, RegexValidationRule: function RegexValidationRule(newValue, threshold) { return 'is geen geldige waarde'; }, @@ -88,6 +91,9 @@ System.register(['../validation/utilities'], function (_export) { }, MediumPasswordValidationRule: function MediumPasswordValidationRule(newValue, threshold) { return 'moet op zijn minst ' + Utilities.getValue(threshold) + ' van de volgende groepen bevatten: letters, hoofdletters, cijfers of speciale tekens'; + }, + URLValidationRule: function URLValidationRule(newValue, threshold) { + return 'is geen geldige URL'; } } }; diff --git a/dist/system/resources/sv-SE.js b/dist/system/resources/sv-SE.js index a3676ac3..c2ae6a3b 100644 --- a/dist/system/resources/sv-SE.js +++ b/dist/system/resources/sv-SE.js @@ -77,6 +77,9 @@ System.register(['../validation/utilities'], function (_export) { NumericValidationRule: function NumericValidationRule(newValue, threshold) { return 'måste vara ett nummer'; }, + NoSpacesValidationRule: function NoSpacesValidationRule(newValue, threshold) { + return 'kan inte innehålla mellanslag'; + }, RegexValidationRule: function RegexValidationRule(newValue, threshold) { return 'är inte ett giltigt värde'; }, @@ -88,6 +91,9 @@ System.register(['../validation/utilities'], function (_export) { }, MediumPasswordValidationRule: function MediumPasswordValidationRule(newValue, threshold) { return 'ska innehålla minst ' + Utilities.getValue(threshold) + ' av följande grupperingar: gemener, versaler, siffror eller specialtecken'; + }, + URLValidationRule: function URLValidationRule(newValue, threshold) { + return 'är inte en giltig webbadress'; } } }; diff --git a/dist/system/resources/tr-TR.js b/dist/system/resources/tr-TR.js index 431ed6a5..a5b12324 100644 --- a/dist/system/resources/tr-TR.js +++ b/dist/system/resources/tr-TR.js @@ -77,6 +77,9 @@ System.register(['../validation/utilities'], function (_export) { NumericValidationRule: function NumericValidationRule(newValue, threshold) { return 'sadece sayı girebilirsiniz'; }, + NoSpacesValidationRule: function NoSpacesValidationRule(newValue, threshold) { + return 'boşluk içeremez'; + }, RegexValidationRule: function RegexValidationRule(newValue, threshold) { return 'geçerli bir değer giriniz'; }, @@ -88,6 +91,9 @@ System.register(['../validation/utilities'], function (_export) { }, MediumPasswordValidationRule: function MediumPasswordValidationRule(newValue, threshold) { return 'küçük harfler, büyük harfler, sayılar veya işaretlerden en az ' + Utilities.getValue(threshold) + ' değişik tip olmalı'; + }, + URLValidationRule: function URLValidationRule(newValue, threshold) { + return 'Geçerli bir URL değil'; } } }; diff --git a/dist/system/validation/path-observer.js b/dist/system/validation/path-observer.js index 68634dc6..d42f7227 100644 --- a/dist/system/validation/path-observer.js +++ b/dist/system/validation/path-observer.js @@ -79,7 +79,7 @@ System.register(['aurelia-binding'], function (_export) { PathObserver.prototype.observePart = function observePart(part) { if (part !== this.path[this.path.length - 1]) { - this.observerParts(); + this.observeParts(); } }; diff --git a/dist/system/validation/validate-custom-attribute.js b/dist/system/validation/validate-custom-attribute.js index c44cdd5e..2405d34d 100644 --- a/dist/system/validation/validate-custom-attribute.js +++ b/dist/system/validation/validate-custom-attribute.js @@ -1,12 +1,11 @@ System.register(['aurelia-dependency-injection', 'aurelia-templating'], function (_export) { - var inject, customAttribute, Behavior, _classCallCheck, ValidateCustomAttribute; + var inject, customAttribute, _classCallCheck, ValidateCustomAttribute; return { setters: [function (_aureliaDependencyInjection) { inject = _aureliaDependencyInjection.inject; }, function (_aureliaTemplating) { customAttribute = _aureliaTemplating.customAttribute; - Behavior = _aureliaTemplating.Behavior; }], execute: function () { 'use strict'; diff --git a/dist/system/validation/validation-config.js b/dist/system/validation/validation-config.js index 58d492d8..20d0ab2c 100644 --- a/dist/system/validation/validation-config.js +++ b/dist/system/validation/validation-config.js @@ -66,7 +66,7 @@ System.register(['../validation/validation-locale', '../validation/validate-cust _this.changedHandlers.set(id, callback); return { v: function () { - changedHandlers['delete'](id); + _this.changedHandlers['delete'](id); } }; })(); diff --git a/dist/system/validation/validation-group-builder.js b/dist/system/validation/validation-group-builder.js index 9fe809bd..1ad64167 100644 --- a/dist/system/validation/validation-group-builder.js +++ b/dist/system/validation/validation-group-builder.js @@ -101,6 +101,10 @@ System.register(['../validation/validation-rules', '../validation/validation-rul return this.passesRule(new AllRules.EmailValidationRule()); }; + ValidationGroupBuilder.prototype.isURL = function isURL() { + return this.passesRule(new AllRules.URLValidationRule()); + }; + ValidationGroupBuilder.prototype.hasMinLength = function hasMinLength(minimumValue) { return this.passesRule(new AllRules.MinimumLengthValidationRule(minimumValue)); }; @@ -117,6 +121,10 @@ System.register(['../validation/validation-rules', '../validation/validation-rul return this.passesRule(new AllRules.NumericValidationRule()); }; + ValidationGroupBuilder.prototype.containsNoSpaces = function containsNoSpaces() { + return this.passesRule(new AllRules.NoSpacesValidationRule()); + }; + ValidationGroupBuilder.prototype.containsOnlyDigits = function containsOnlyDigits() { return this.passesRule(new AllRules.DigitValidationRule()); }; diff --git a/dist/system/validation/validation-group.js b/dist/system/validation/validation-group.js index f8bbd2db..a24748ae 100644 --- a/dist/system/validation/validation-group.js +++ b/dist/system/validation/validation-group.js @@ -220,6 +220,10 @@ System.register(['../validation/validation-group-builder', '../validation/valida return this.builder.isEmail(); }; + ValidationGroup.prototype.isURL = function isURL() { + return this.builder.isURL(); + }; + ValidationGroup.prototype.isIn = function isIn(collection) { return this.builder.isIn(collection); }; @@ -240,6 +244,10 @@ System.register(['../validation/validation-group-builder', '../validation/valida return this.builder.isNumber(); }; + ValidationGroup.prototype.containsNoSpaces = function containsNoSpaces() { + return this.builder.containsNoSpaces(); + }; + ValidationGroup.prototype.containsOnlyDigits = function containsOnlyDigits() { return this.builder.containsOnlyDigits(); }; diff --git a/dist/system/validation/validation-property.js b/dist/system/validation/validation-property.js index 18772a5c..56dffce5 100644 --- a/dist/system/validation/validation-property.js +++ b/dist/system/validation/validation-property.js @@ -54,7 +54,7 @@ System.register(['../validation/validation-rules-collection', '../validation/pat } ValidationProperty.prototype.addValidationRule = function addValidationRule(validationRule) { - if (validationRule.validate === undefined) throw new exception('That\'s not a valid validationRule'); + if (validationRule.validate === undefined) throw new Error('That\'s not a valid validationRule'); this.collectionOfValidationRules.addValidationRule(validationRule); this.validateCurrentValue(false); }; diff --git a/dist/system/validation/validation-rules-collection.js b/dist/system/validation/validation-rules-collection.js index e379cf89..13602435 100644 --- a/dist/system/validation/validation-rules-collection.js +++ b/dist/system/validation/validation-rules-collection.js @@ -97,7 +97,7 @@ System.register(['../validation/utilities', '../validation/validation-locale'], }; ValidationRulesCollection.prototype.addValidationRule = function addValidationRule(validationRule) { - if (validationRule.validate === undefined) throw new exception('That\'s not a valid validationRule'); + if (validationRule.validate === undefined) throw new Error('That\'s not a valid validationRule'); this.validationRules.push(validationRule); }; diff --git a/dist/system/validation/validation-rules.js b/dist/system/validation/validation-rules.js index 1533fd76..724b0def 100644 --- a/dist/system/validation/validation-rules.js +++ b/dist/system/validation/validation-rules.js @@ -1,5 +1,5 @@ System.register(['../validation/utilities', '../validation/validation-locale'], function (_export) { - var Utilities, ValidationLocale, _inherits, _classCallCheck, ValidationRule, EmailValidationRule, MinimumLengthValidationRule, MaximumLengthValidationRule, BetweenLengthValidationRule, CustomFunctionValidationRule, NumericValidationRule, RegexValidationRule, ContainsOnlyValidationRule, MinimumValueValidationRule, MinimumInclusiveValueValidationRule, MaximumValueValidationRule, MaximumInclusiveValueValidationRule, BetweenValueValidationRule, DigitValidationRule, AlphaNumericValidationRule, AlphaValidationRule, AlphaOrWhitespaceValidationRule, AlphaNumericOrWhitespaceValidationRule, MediumPasswordValidationRule, StrongPasswordValidationRule, EqualityValidationRuleBase, EqualityValidationRule, EqualityWithOtherLabelValidationRule, InEqualityValidationRule, InEqualityWithOtherLabelValidationRule, InCollectionValidationRule; + var Utilities, ValidationLocale, _inherits, _classCallCheck, ValidationRule, URLValidationRule, EmailValidationRule, MinimumLengthValidationRule, MaximumLengthValidationRule, BetweenLengthValidationRule, CustomFunctionValidationRule, NumericValidationRule, RegexValidationRule, ContainsOnlyValidationRule, MinimumValueValidationRule, MinimumInclusiveValueValidationRule, MaximumValueValidationRule, MaximumInclusiveValueValidationRule, BetweenValueValidationRule, DigitValidationRule, NoSpacesValidationRule, AlphaNumericValidationRule, AlphaValidationRule, AlphaOrWhitespaceValidationRule, AlphaNumericOrWhitespaceValidationRule, MediumPasswordValidationRule, StrongPasswordValidationRule, EqualityValidationRuleBase, EqualityValidationRule, EqualityWithOtherLabelValidationRule, InEqualityValidationRule, InEqualityWithOtherLabelValidationRule, InCollectionValidationRule; return { setters: [function (_validationUtilities) { @@ -79,13 +79,174 @@ System.register(['../validation/utilities', '../validation/validation-locale'], _export('ValidationRule', ValidationRule); - EmailValidationRule = (function (_ValidationRule) { - function EmailValidationRule() { + URLValidationRule = (function (_ValidationRule) { + function URLValidationRule(threshold) { var _this2 = this; + _classCallCheck(this, URLValidationRule); + + var default_url_options = { + protocols: ['http', 'https', 'ftp'], + require_tld: true, + require_protocol: false, + allow_underscores: true, + allow_trailing_dot: false, + allow_protocol_relative_urls: true + }; + if (threshold === undefined) { + threshold = default_url_options; + } + + _ValidationRule.call(this, threshold, function (newValue, threshold) { + var url = newValue; + if (!url || url.length >= 2083 || /\s/.test(url)) { + return false; + } + if (url.indexOf('mailto:') === 0) { + return false; + } + var protocol, auth, host, hostname, port, port_str, split; + split = url.split('://'); + if (split.length > 1) { + protocol = split.shift(); + if (threshold.protocols.indexOf(protocol) === -1) { + return false; + } + } else if (threshold.require_protocol) { + return false; + } else if (threshold.allow_protocol_relative_urls && url.substr(0, 2) === '//') { + split[0] = url.substr(2); + } + url = split.join('://'); + split = url.split('#'); + url = split.shift(); + + split = url.split('?'); + url = split.shift(); + + split = url.split('/'); + url = split.shift(); + split = url.split('@'); + if (split.length > 1) { + auth = split.shift(); + if (auth.indexOf(':') >= 0 && auth.split(':').length > 2) { + return false; + } + } + hostname = split.join('@'); + split = hostname.split(':'); + host = split.shift(); + if (split.length) { + port_str = split.join(':'); + port = parseInt(port_str, 10); + if (!/^[0-9]+$/.test(port_str) || port <= 0 || port > 65535) { + return false; + } + } + if (!_this2.isIP(host) && !_this2.isFQDN(host, threshold) && host !== 'localhost') { + return false; + } + if (threshold.host_whitelist && threshold.host_whitelist.indexOf(host) === -1) { + return false; + } + if (threshold.host_blacklist && threshold.host_blacklist.indexOf(host) !== -1) { + return false; + } + return true; + }); + this.isIP = function (str, version) { + var ipv4Maybe = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/, + ipv6Block = /^[0-9A-F]{1,4}$/i; + + if (!version) { + return this.isIP(str, 4) || this.isIP(str, 6); + } else if (version === 4) { + if (!ipv4Maybe.test(str)) { + return false; + } + var parts = str.split('.').sort(function (a, b) { + return a - b; + }); + return parts[3] <= 255; + } else if (version === 6) { + var blocks = str.split(':'); + var foundOmissionBlock = false; + + if (blocks.length > 8) return false; + + if (str === '::') { + return true; + } else if (str.substr(0, 2) === '::') { + blocks.shift(); + blocks.shift(); + foundOmissionBlock = true; + } else if (str.substr(str.length - 2) === '::') { + blocks.pop(); + blocks.pop(); + foundOmissionBlock = true; + } + + for (var i = 0; i < blocks.length; ++i) { + if (blocks[i] === '' && i > 0 && i < blocks.length - 1) { + if (foundOmissionBlock) return false; + foundOmissionBlock = true; + } else if (!ipv6Block.test(blocks[i])) { + return false; + } + } + + if (foundOmissionBlock) { + return blocks.length >= 1; + } else { + return blocks.length === 8; + } + } + return false; + }; + this.isFQDN = function (str, options) { + if (options.allow_trailing_dot && str[str.length - 1] === '.') { + str = str.substring(0, str.length - 1); + } + var parts = str.split('.'); + if (options.require_tld) { + var tld = parts.pop(); + if (!parts.length || !/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) { + return false; + } + } + for (var part, i = 0; i < parts.length; i++) { + part = parts[i]; + if (options.allow_underscores) { + if (part.indexOf('__') >= 0) { + return false; + } + part = part.replace(/_/g, ''); + } + if (!/^[a-z\u00a1-\uffff0-9-]+$/i.test(part)) { + return false; + } + if (part[0] === '-' || part[part.length - 1] === '-' || part.indexOf('---') >= 0) { + return false; + } + } + return true; + }; + } + + _inherits(URLValidationRule, _ValidationRule); + + return URLValidationRule; + })(ValidationRule); + + _export('URLValidationRule', URLValidationRule); + + EmailValidationRule = (function (_ValidationRule2) { + function EmailValidationRule() { + var _this3 = this; + _classCallCheck(this, EmailValidationRule); - _ValidationRule.call(this, null, function (newValue, threshold) { + _ValidationRule2.call(this, null, function (newValue, threshold) { if (/\s/.test(newValue)) { return false; } @@ -93,10 +254,10 @@ System.register(['../validation/utilities', '../validation/validation-locale'], var domain = parts.pop(); var user = parts.join('@'); - if (!_this2.isFQDN(domain)) { + if (!_this3.isFQDN(domain)) { return false; } - return _this2.emailUserUtf8Regex.test(user); + return _this3.emailUserUtf8Regex.test(user); }); this.emailUserUtf8Regex = /^((([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)))$/i; this.isFQDN = function (str) { @@ -118,103 +279,103 @@ System.register(['../validation/utilities', '../validation/validation-locale'], }; } - _inherits(EmailValidationRule, _ValidationRule); + _inherits(EmailValidationRule, _ValidationRule2); return EmailValidationRule; })(ValidationRule); _export('EmailValidationRule', EmailValidationRule); - MinimumLengthValidationRule = (function (_ValidationRule2) { + MinimumLengthValidationRule = (function (_ValidationRule3) { function MinimumLengthValidationRule(minimumLength) { _classCallCheck(this, MinimumLengthValidationRule); - _ValidationRule2.call(this, minimumLength, function (newValue, minimumLength) { + _ValidationRule3.call(this, minimumLength, function (newValue, minimumLength) { return newValue.length !== undefined && newValue.length >= minimumLength; }); } - _inherits(MinimumLengthValidationRule, _ValidationRule2); + _inherits(MinimumLengthValidationRule, _ValidationRule3); return MinimumLengthValidationRule; })(ValidationRule); _export('MinimumLengthValidationRule', MinimumLengthValidationRule); - MaximumLengthValidationRule = (function (_ValidationRule3) { + MaximumLengthValidationRule = (function (_ValidationRule4) { function MaximumLengthValidationRule(maximumLength) { _classCallCheck(this, MaximumLengthValidationRule); - _ValidationRule3.call(this, maximumLength, function (newValue, maximumLength) { + _ValidationRule4.call(this, maximumLength, function (newValue, maximumLength) { return newValue.length !== undefined && newValue.length <= maximumLength; }); } - _inherits(MaximumLengthValidationRule, _ValidationRule3); + _inherits(MaximumLengthValidationRule, _ValidationRule4); return MaximumLengthValidationRule; })(ValidationRule); _export('MaximumLengthValidationRule', MaximumLengthValidationRule); - BetweenLengthValidationRule = (function (_ValidationRule4) { + BetweenLengthValidationRule = (function (_ValidationRule5) { function BetweenLengthValidationRule(minimumLength, maximumLength) { _classCallCheck(this, BetweenLengthValidationRule); - _ValidationRule4.call(this, { minimumLength: minimumLength, maximumLength: maximumLength }, function (newValue, threshold) { + _ValidationRule5.call(this, { minimumLength: minimumLength, maximumLength: maximumLength }, function (newValue, threshold) { return newValue.length !== undefined && newValue.length >= threshold.minimumLength && newValue.length <= threshold.maximumLength; }); } - _inherits(BetweenLengthValidationRule, _ValidationRule4); + _inherits(BetweenLengthValidationRule, _ValidationRule5); return BetweenLengthValidationRule; })(ValidationRule); _export('BetweenLengthValidationRule', BetweenLengthValidationRule); - CustomFunctionValidationRule = (function (_ValidationRule5) { + CustomFunctionValidationRule = (function (_ValidationRule6) { function CustomFunctionValidationRule(customFunction, threshold) { _classCallCheck(this, CustomFunctionValidationRule); - _ValidationRule5.call(this, threshold, customFunction); + _ValidationRule6.call(this, threshold, customFunction); } - _inherits(CustomFunctionValidationRule, _ValidationRule5); + _inherits(CustomFunctionValidationRule, _ValidationRule6); return CustomFunctionValidationRule; })(ValidationRule); _export('CustomFunctionValidationRule', CustomFunctionValidationRule); - NumericValidationRule = (function (_ValidationRule6) { + NumericValidationRule = (function (_ValidationRule7) { function NumericValidationRule() { _classCallCheck(this, NumericValidationRule); - _ValidationRule6.call(this, null, function (newValue, threshold, locale) { + _ValidationRule7.call(this, null, function (newValue, threshold, locale) { var numericRegex = locale.setting('numericRegex'); var floatValue = parseFloat(newValue); - return !Number.isNaN(parseFloat(floatValue)) && Number.isFinite(floatValue) && numericRegex.test(newValue); + return !Number.isNaN(parseFloat(newValue)) && Number.isFinite(floatValue) && numericRegex.test(newValue); }); } - _inherits(NumericValidationRule, _ValidationRule6); + _inherits(NumericValidationRule, _ValidationRule7); return NumericValidationRule; })(ValidationRule); _export('NumericValidationRule', NumericValidationRule); - RegexValidationRule = (function (_ValidationRule7) { + RegexValidationRule = (function (_ValidationRule8) { function RegexValidationRule(regex) { _classCallCheck(this, RegexValidationRule); - _ValidationRule7.call(this, regex, function (newValue, regex) { + _ValidationRule8.call(this, regex, function (newValue, regex) { return regex.test(newValue); }); } - _inherits(RegexValidationRule, _ValidationRule7); + _inherits(RegexValidationRule, _ValidationRule8); return RegexValidationRule; })(ValidationRule); @@ -235,186 +396,205 @@ System.register(['../validation/utilities', '../validation/validation-locale'], _export('ContainsOnlyValidationRule', ContainsOnlyValidationRule); - MinimumValueValidationRule = (function (_ValidationRule8) { + MinimumValueValidationRule = (function (_ValidationRule9) { function MinimumValueValidationRule(minimumValue) { _classCallCheck(this, MinimumValueValidationRule); - _ValidationRule8.call(this, minimumValue, function (newValue, minimumValue) { + _ValidationRule9.call(this, minimumValue, function (newValue, minimumValue) { return Utilities.getValue(minimumValue) < newValue; }); } - _inherits(MinimumValueValidationRule, _ValidationRule8); + _inherits(MinimumValueValidationRule, _ValidationRule9); return MinimumValueValidationRule; })(ValidationRule); _export('MinimumValueValidationRule', MinimumValueValidationRule); - MinimumInclusiveValueValidationRule = (function (_ValidationRule9) { + MinimumInclusiveValueValidationRule = (function (_ValidationRule10) { function MinimumInclusiveValueValidationRule(minimumValue) { _classCallCheck(this, MinimumInclusiveValueValidationRule); - _ValidationRule9.call(this, minimumValue, function (newValue, minimumValue) { + _ValidationRule10.call(this, minimumValue, function (newValue, minimumValue) { return Utilities.getValue(minimumValue) <= newValue; }); } - _inherits(MinimumInclusiveValueValidationRule, _ValidationRule9); + _inherits(MinimumInclusiveValueValidationRule, _ValidationRule10); return MinimumInclusiveValueValidationRule; })(ValidationRule); _export('MinimumInclusiveValueValidationRule', MinimumInclusiveValueValidationRule); - MaximumValueValidationRule = (function (_ValidationRule10) { + MaximumValueValidationRule = (function (_ValidationRule11) { function MaximumValueValidationRule(maximumValue) { _classCallCheck(this, MaximumValueValidationRule); - _ValidationRule10.call(this, maximumValue, function (newValue, maximumValue) { + _ValidationRule11.call(this, maximumValue, function (newValue, maximumValue) { return newValue < Utilities.getValue(maximumValue); }); } - _inherits(MaximumValueValidationRule, _ValidationRule10); + _inherits(MaximumValueValidationRule, _ValidationRule11); return MaximumValueValidationRule; })(ValidationRule); _export('MaximumValueValidationRule', MaximumValueValidationRule); - MaximumInclusiveValueValidationRule = (function (_ValidationRule11) { + MaximumInclusiveValueValidationRule = (function (_ValidationRule12) { function MaximumInclusiveValueValidationRule(maximumValue) { _classCallCheck(this, MaximumInclusiveValueValidationRule); - _ValidationRule11.call(this, maximumValue, function (newValue, maximumValue) { + _ValidationRule12.call(this, maximumValue, function (newValue, maximumValue) { return newValue <= Utilities.getValue(maximumValue); }); } - _inherits(MaximumInclusiveValueValidationRule, _ValidationRule11); + _inherits(MaximumInclusiveValueValidationRule, _ValidationRule12); return MaximumInclusiveValueValidationRule; })(ValidationRule); _export('MaximumInclusiveValueValidationRule', MaximumInclusiveValueValidationRule); - BetweenValueValidationRule = (function (_ValidationRule12) { + BetweenValueValidationRule = (function (_ValidationRule13) { function BetweenValueValidationRule(minimumValue, maximumValue) { _classCallCheck(this, BetweenValueValidationRule); - _ValidationRule12.call(this, { minimumValue: minimumValue, maximumValue: maximumValue }, function (newValue, threshold) { + _ValidationRule13.call(this, { minimumValue: minimumValue, maximumValue: maximumValue }, function (newValue, threshold) { return Utilities.getValue(threshold.minimumValue) <= newValue && newValue <= Utilities.getValue(threshold.maximumValue); }); } - _inherits(BetweenValueValidationRule, _ValidationRule12); + _inherits(BetweenValueValidationRule, _ValidationRule13); return BetweenValueValidationRule; })(ValidationRule); _export('BetweenValueValidationRule', BetweenValueValidationRule); - DigitValidationRule = (function (_ValidationRule13) { + DigitValidationRule = (function (_ValidationRule14) { function DigitValidationRule() { - var _this3 = this; + var _this4 = this; _classCallCheck(this, DigitValidationRule); - _ValidationRule13.call(this, null, function (newValue, threshold) { - return _this3.digitRegex.test(newValue); + _ValidationRule14.call(this, null, function (newValue, threshold) { + return _this4.digitRegex.test(newValue); }); this.digitRegex = /^\d+$/; } - _inherits(DigitValidationRule, _ValidationRule13); + _inherits(DigitValidationRule, _ValidationRule14); return DigitValidationRule; })(ValidationRule); _export('DigitValidationRule', DigitValidationRule); - AlphaNumericValidationRule = (function (_ValidationRule14) { + NoSpacesValidationRule = (function (_ValidationRule15) { + function NoSpacesValidationRule() { + var _this5 = this; + + _classCallCheck(this, NoSpacesValidationRule); + + _ValidationRule15.call(this, null, function (newValue, threshold) { + return _this5.regex.test(newValue); + }); + this.regex = /^\S*$/; + } + + _inherits(NoSpacesValidationRule, _ValidationRule15); + + return NoSpacesValidationRule; + })(ValidationRule); + + _export('NoSpacesValidationRule', NoSpacesValidationRule); + + AlphaNumericValidationRule = (function (_ValidationRule16) { function AlphaNumericValidationRule() { - var _this4 = this; + var _this6 = this; _classCallCheck(this, AlphaNumericValidationRule); - _ValidationRule14.call(this, null, function (newValue, threshold) { - return _this4.alphaNumericRegex.test(newValue); + _ValidationRule16.call(this, null, function (newValue, threshold) { + return _this6.alphaNumericRegex.test(newValue); }); this.alphaNumericRegex = /^[a-z0-9]+$/i; } - _inherits(AlphaNumericValidationRule, _ValidationRule14); + _inherits(AlphaNumericValidationRule, _ValidationRule16); return AlphaNumericValidationRule; })(ValidationRule); _export('AlphaNumericValidationRule', AlphaNumericValidationRule); - AlphaValidationRule = (function (_ValidationRule15) { + AlphaValidationRule = (function (_ValidationRule17) { function AlphaValidationRule() { - var _this5 = this; + var _this7 = this; _classCallCheck(this, AlphaValidationRule); - _ValidationRule15.call(this, null, function (newValue, threshold) { - return _this5.alphaRegex.test(newValue); + _ValidationRule17.call(this, null, function (newValue, threshold) { + return _this7.alphaRegex.test(newValue); }); this.alphaRegex = /^[a-z]+$/i; } - _inherits(AlphaValidationRule, _ValidationRule15); + _inherits(AlphaValidationRule, _ValidationRule17); return AlphaValidationRule; })(ValidationRule); _export('AlphaValidationRule', AlphaValidationRule); - AlphaOrWhitespaceValidationRule = (function (_ValidationRule16) { + AlphaOrWhitespaceValidationRule = (function (_ValidationRule18) { function AlphaOrWhitespaceValidationRule() { - var _this6 = this; + var _this8 = this; _classCallCheck(this, AlphaOrWhitespaceValidationRule); - _ValidationRule16.call(this, null, function (newValue, threshold) { - return _this6.alphaNumericRegex.test(newValue); + _ValidationRule18.call(this, null, function (newValue, threshold) { + return _this8.alphaNumericRegex.test(newValue); }); this.alphaNumericRegex = /^[a-z\s]+$/i; } - _inherits(AlphaOrWhitespaceValidationRule, _ValidationRule16); + _inherits(AlphaOrWhitespaceValidationRule, _ValidationRule18); return AlphaOrWhitespaceValidationRule; })(ValidationRule); _export('AlphaOrWhitespaceValidationRule', AlphaOrWhitespaceValidationRule); - AlphaNumericOrWhitespaceValidationRule = (function (_ValidationRule17) { + AlphaNumericOrWhitespaceValidationRule = (function (_ValidationRule19) { function AlphaNumericOrWhitespaceValidationRule() { - var _this7 = this; + var _this9 = this; _classCallCheck(this, AlphaNumericOrWhitespaceValidationRule); - _ValidationRule17.call(this, null, function (newValue, threshold) { - return _this7.alphaNumericRegex.test(newValue); + _ValidationRule19.call(this, null, function (newValue, threshold) { + return _this9.alphaNumericRegex.test(newValue); }); this.alphaNumericRegex = /^[a-z0-9\s]+$/i; } - _inherits(AlphaNumericOrWhitespaceValidationRule, _ValidationRule17); + _inherits(AlphaNumericOrWhitespaceValidationRule, _ValidationRule19); return AlphaNumericOrWhitespaceValidationRule; })(ValidationRule); _export('AlphaNumericOrWhitespaceValidationRule', AlphaNumericOrWhitespaceValidationRule); - MediumPasswordValidationRule = (function (_ValidationRule18) { + MediumPasswordValidationRule = (function (_ValidationRule20) { function MediumPasswordValidationRule(minimumComplexityLevel) { _classCallCheck(this, MediumPasswordValidationRule); - _ValidationRule18.call(this, minimumComplexityLevel ? minimumComplexityLevel : 3, function (newValue, threshold) { + _ValidationRule20.call(this, minimumComplexityLevel ? minimumComplexityLevel : 3, function (newValue, threshold) { if (typeof newValue !== 'string') return false; var strength = 0; @@ -426,7 +606,7 @@ System.register(['../validation/utilities', '../validation/validation-locale'], }); } - _inherits(MediumPasswordValidationRule, _ValidationRule18); + _inherits(MediumPasswordValidationRule, _ValidationRule20); return MediumPasswordValidationRule; })(ValidationRule); @@ -447,11 +627,11 @@ System.register(['../validation/utilities', '../validation/validation-locale'], _export('StrongPasswordValidationRule', StrongPasswordValidationRule); - EqualityValidationRuleBase = (function (_ValidationRule19) { + EqualityValidationRuleBase = (function (_ValidationRule21) { function EqualityValidationRuleBase(otherValue, equality, otherValueLabel) { _classCallCheck(this, EqualityValidationRuleBase); - _ValidationRule19.call(this, { + _ValidationRule21.call(this, { otherValue: otherValue, equality: equality, otherValueLabel: otherValueLabel @@ -462,7 +642,7 @@ System.register(['../validation/utilities', '../validation/validation-locale'], }); } - _inherits(EqualityValidationRuleBase, _ValidationRule19); + _inherits(EqualityValidationRuleBase, _ValidationRule21); return EqualityValidationRuleBase; })(ValidationRule); @@ -525,11 +705,11 @@ System.register(['../validation/utilities', '../validation/validation-locale'], _export('InEqualityWithOtherLabelValidationRule', InEqualityWithOtherLabelValidationRule); - InCollectionValidationRule = (function (_ValidationRule20) { + InCollectionValidationRule = (function (_ValidationRule22) { function InCollectionValidationRule(collection) { _classCallCheck(this, InCollectionValidationRule); - _ValidationRule20.call(this, collection, function (newValue, threshold) { + _ValidationRule22.call(this, collection, function (newValue, threshold) { var collection = Utilities.getValue(threshold); for (var i = 0; i < collection.length; i++) { if (newValue === collection[i]) return true; @@ -538,7 +718,7 @@ System.register(['../validation/utilities', '../validation/validation-locale'], }); } - _inherits(InCollectionValidationRule, _ValidationRule20); + _inherits(InCollectionValidationRule, _ValidationRule22); return InCollectionValidationRule; })(ValidationRule);