From 8edf98d11d5249ec08cb1360c185bb1d368a6e8f Mon Sep 17 00:00:00 2001 From: Stuart Date: Wed, 11 Sep 2019 11:16:55 -0400 Subject: [PATCH] version 1.2.4 --- bower.json | 2 +- dist/locale/es.js | 2 +- dist/locale/fr.js | 2 +- dist/locale/min/es.min.js | 2 +- dist/locale/min/fr.min.js | 2 +- dist/locale/min/sr.min.js | 2 ++ dist/locale/min/template-en.min.js | 2 +- dist/locale/sr.js | 51 ++++++++++++++++++++++++++++++ dist/locale/template-en.js | 2 +- dist/simple-react-validator.js | 14 ++++---- dist/simple-react-validator.min.js | 4 +-- gulpfile.js | 2 +- package-lock.json | 2 +- package.json | 2 +- src/simple-react-validator.js | 10 +++--- 15 files changed, 79 insertions(+), 22 deletions(-) create mode 100644 dist/locale/min/sr.min.js create mode 100644 dist/locale/sr.js diff --git a/bower.json b/bower.json index 40ddb62..4cc94a4 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "simple-react-validator", "description": "A simple react form validator inspired by Laravel validation.", "main": "dist/simple-react-validator.min.js", - "version": "1.2.3", + "version": "1.2.4", "authors": [ "Stuart Yamartino" ], diff --git a/dist/locale/es.js b/dist/locale/es.js index 13eb4f8..231c168 100644 --- a/dist/locale/es.js +++ b/dist/locale/es.js @@ -1,4 +1,4 @@ -// Simple React Validator v1.2.3 | Created By Dockwa | MIT License | 2017 - Present +// Simple React Validator v1.2.4 | Created By Dockwa | MIT License | 2017 - Present ;(function(root, factory) { if (typeof define === 'function' && define.amd) { define(['simple-react-validator'], factory); diff --git a/dist/locale/fr.js b/dist/locale/fr.js index cc1f71e..583eb50 100644 --- a/dist/locale/fr.js +++ b/dist/locale/fr.js @@ -1,4 +1,4 @@ -// Simple React Validator v1.2.3 | Created By Dockwa | MIT License | 2017 - Present +// Simple React Validator v1.2.4 | Created By Dockwa | MIT License | 2017 - Present ;(function(root, factory) { if (typeof define === 'function' && define.amd) { define(['simple-react-validator'], factory); diff --git a/dist/locale/min/es.min.js b/dist/locale/min/es.min.js index 8b08435..105784a 100644 --- a/dist/locale/min/es.min.js +++ b/dist/locale/min/es.min.js @@ -1,2 +1,2 @@ -// Simple React Validator v1.2.3 | Created By Dockwa | MIT License | 2017 - Present +// Simple React Validator v1.2.4 | Created By Dockwa | MIT License | 2017 - Present !function(e,t){"function"==typeof define&&define.amd?define(["simple-react-validator"],t):"object"==typeof exports?module.exports=t(require("simple-react-validator")):e.SimpleReactValidatorLocaleEs=t(e.SimpleReactValidator)}(this,function(e){"use strict";var t={accepted:":attribute debe ser aceptado.",after:":attribute debe ser una fecha posterior a :date.",after_or_equal:":attribute debe ser una fecha posterior o igual a :date.",alpha:":attribute sólo debe contener letras.",array:":attribute debe ser un conjunto.",before:":attribute debe ser una fecha anterior a :date.",before_or_equal:":attribute debe ser una fecha anterior o igual a :date.",between:":attribute tiene que estar entre :min - :max:type.",boolean:"El campo :attribute debe tener un valor verdadero o falso.",date:":attribute no es una fecha válida.",date_equals:":attribute debe ser una fecha igual a :date.",email:":attribute no es un correo válido",in:":attribute es inválido :values.",integer:":attribute debe ser un número entero.",max:":attribute no debe ser mayor a :max:type.",min:"El tamaño de :attribute debe ser de al menos :min:type.",not_in:":attribute es inválido :values.",not_regex:"El formato del campo :attribute no es válido.",numeric:":attribute debe ser numérico.",regex:"El formato de :attribute es inválido.",required:"El campo :attribute es obligatorio.",size:"El tamaño de :attribute debe ser :size:type.",string:"El campo :attribute debe ser una cadena de caracteres.",url:"El formato :attribute es inválido."};return e.addLocale("es",t),t}); \ No newline at end of file diff --git a/dist/locale/min/fr.min.js b/dist/locale/min/fr.min.js index 886f7a3..2375d73 100644 --- a/dist/locale/min/fr.min.js +++ b/dist/locale/min/fr.min.js @@ -1,2 +1,2 @@ -// Simple React Validator v1.2.3 | Created By Dockwa | MIT License | 2017 - Present +// Simple React Validator v1.2.4 | Created By Dockwa | MIT License | 2017 - Present !function(e,t){"function"==typeof define&&define.amd?define(["simple-react-validator"],t):"object"==typeof exports?module.exports=t(require("simple-react-validator")):e.SimpleReactValidatorLocaleFr=t(e.SimpleReactValidator)}(this,function(e){"use strict";var t={accepted:"Le champ :attribute doit être accepté.",after:"Le champ :attribute doit être après :date.",after_or_equal:"Le champ :attribute doit correspondre ou bien être après :date.",alpha:"Le champ :attribute ne peut contenir que des lettres.",alpha_space:"Le champ :attribute ne peut contenir que des lettres et des espaces.",alpha_num:"Le champ :attribute ne peut contenir que des lettres et des chiffres.",alpha_num_space:"Le champ :attribute ne peut contenir que des lettres, chiffres, et espaces.",alpha_num_dash:"Le champ :attribute ne peut contenir que des lettres, chiffres, et tirets.",alpha_num_dash_space:"Le champ :attribute ne peut contenir que des lettres, chiffres, tirets, et espaces.",array:"Le champ :attribute doit êttre un tableau.",before:"Le champ :attribute doit être avant :date.",before_or_equal:"Le champ :attribute doit correspondre ou bien être avant :date.",between:"Le champ :attribute doit être entre :min et :max:type.",boolean:"Le champ :attribute doit être booléen.",card_exp:"Le champ :attribute doit être une date d'expiration valide.",card_num:"Le champ :attribute doit être un numéro valide de carte de crédit .",currency:"Le champ :attribute doit être une devise valide.",date:"Le champ :attribute doit être une date.",date_equals:"Le champ :attribute doit correspondre à :date.",email:"Le champ :attribute doit êre une adresse email valide.",in:"Le champ selectionné :attribute doit être :values.",integer:"Le champ :attribute doit être un entier.",max:"Le champ :attribute ne doit pas dépasser :max:type.",min:"Le champ :attribute doit au moins être :min:type.",not_in:"Le champ selectionné :attribute ne doit pas être :values.",not_regex:"Le champ :attribute ne doit pas correspondre au motif requis.",numeric:"Le champ :attribute doit être un chiffre.",phone:"Le champ :attribute doit être un numéro de téléphone valide.",regex:"Le champ :attribute doit correspondre au motif requis.",required:"Le champ :attribute est requis.",size:"Le champ :attribute doit être :size:type.",string:"Le champ :attribute doit être une chaîne.",typeof:"Le champ :attribute n'est pas le type correcte de :type.",url:"Le champ :attribute doit être un url."};return e.addLocale("fr",t),t}); \ No newline at end of file diff --git a/dist/locale/min/sr.min.js b/dist/locale/min/sr.min.js new file mode 100644 index 0000000..e439a20 --- /dev/null +++ b/dist/locale/min/sr.min.js @@ -0,0 +1,2 @@ +// Simple React Validator v1.2.4 | Created By Dockwa | MIT License | 2017 - Present +!function(e,t){"function"==typeof define&&define.amd?define(["simple-react-validator"],t):"object"==typeof exports?module.exports=t(require("simple-react-validator")):e.SimpleReactValidatorLocaleSr=t(e.SimpleReactValidator)}(this,function(e){"use strict";var t={accepted:"Polje :attribute mora biti prihvaćeno.",after:"Polje :attribute mora biti nakon :date.",after_or_equal:"Polje :attribute mora biti nakon ili na :date.",alpha:"Polje :attribute može sadržati samo slova.",alpha_space:"Polje :attribute može sadržati samo slova i razmake.",alpha_num:"Polje :attribute može sadržati samo slova i brojeve.",alpha_num_space:"Polje :attribute može sadržati samo slova, brojeve i razmake.",alpha_num_dash:"Polje :attribute može sadržati samo slova, brojeve i crte.",alpha_num_dash_space:"Polje :attribute može sadržati samo slova, brojeve, crte i razmake.",array:"Polje :attribute mora biti niz.",before:"Polje :attribute mora biti pre :date.",before_or_equal:"Polje :attribute mora biti pre ili na :date.",between:"Polje :attribute mora biti između :min i :max:type.",boolean:"Polje :attribute mora biti istinitosna vrednost.",card_exp:"Polje :attribute mora biti validan datum isteka.",card_num:"Polje :attribute mora biti validan broj kreditne kartice.",currency:"Polje :attribute mora biti validna valuta.",date:"Polje :attribute mora biti datum.",date_equals:"Polje :attribute mora biti na :date.",email:"Polje :attribute mora biti validna email adresa.",in:"Izabrano polje :attribute mora biti :values.",integer:"Polje :attribute mora biti ceo broj.",max:"Polje :attribute ne sme biti veće od :max:type.",min:"Polje :attribute mora biti veće od :min:type.",not_in:"Izabrano polje :attribute ne sme biti :values.",not_regex:"Polje :attribute ne sme biti u određenom formatu.",numeric:"Polje :attribute mora biti broj.",phone:"Polje :attribute mora biti validan broj telefona.",regex:"Polje :attribute mora biti u određenom formatu.",required:"Polje :attribute je obavezno.",size:"Polje :attribute mora biti :size:type.",string:"Polje :attribute mora biti niska.",typeof:"Polje :attribute nije ispravan tip :type.",url:"Polje :attribute mora biti URL."};return e.addLocale("sr",t),t}); \ No newline at end of file diff --git a/dist/locale/min/template-en.min.js b/dist/locale/min/template-en.min.js index 38627e5..ead7a29 100644 --- a/dist/locale/min/template-en.min.js +++ b/dist/locale/min/template-en.min.js @@ -1,2 +1,2 @@ -// Simple React Validator v1.2.3 | Created By Dockwa | MIT License | 2017 - Present +// Simple React Validator v1.2.4 | Created By Dockwa | MIT License | 2017 - Present !function(e,t){"function"==typeof define&&define.amd?define(["simple-react-validator"],t):"object"==typeof exports?module.exports=t(require("simple-react-validator")):e.SimpleReactValidatorLocaleTemplateEn=t(e.SimpleReactValidator)}(this,function(e){"use strict";var t={accepted:"The :attribute must be accepted.",after:"The :attribute must be after :date.",after_or_equal:"The :attribute must be after or on :date.",alpha:"The :attribute may only contain letters.",alpha_space:"The :attribute may only contain letters and spaces.",alpha_num:"The :attribute may only contain letters and numbers.",alpha_num_space:"The :attribute may only contain letters, numbers, and spaces.",alpha_num_dash:"The :attribute may only contain letters, numbers, and dashes.",alpha_num_dash_space:"The :attribute may only contain letters, numbers, dashes, and spaces.",array:"The :attribute must be an array.",before:"The :attribute must be before :date.",before_or_equal:"The :attribute must be before or on :date.",between:"The :attribute must be between :min and :max:type.",boolean:"The :attribute must be a boolean.",card_exp:"The :attribute must be a valid expiration date.",card_num:"The :attribute must be a valid credit card number.",currency:"The :attribute must be a valid currency.",date:"The :attribute must be a date.",date_equals:"The :attribute must be on :date.",email:"The :attribute must be a valid email address.",in:"The selected :attribute must be :values.",integer:"The :attribute must be an integer.",max:"The :attribute may not be greater than :max:type.",min:"The :attribute must be at least :min:type.",not_in:"The selected :attribute must not be :values.",not_regex:"The :attribute must not match the required pattern.",numeric:"The :attribute must be a number.",phone:"The :attribute must be a valid phone number.",regex:"The :attribute must match the required pattern.",required:"The :attribute field is required.",size:"The :attribute must be :size:type.",string:"The :attribute must be a string.",typeof:"The :attribute is not the correct type of :type.",url:"The :attribute must be a url."};return e.addLocale("en",t),t}); \ No newline at end of file diff --git a/dist/locale/sr.js b/dist/locale/sr.js new file mode 100644 index 0000000..4e380bc --- /dev/null +++ b/dist/locale/sr.js @@ -0,0 +1,51 @@ +// Simple React Validator v1.2.4 | Created By Dockwa | MIT License | 2017 - Present +;(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['simple-react-validator'], factory); + } else if (typeof exports === 'object') { + module.exports = factory(require('simple-react-validator')); + } else { + root.SimpleReactValidatorLocaleSr = factory(root.SimpleReactValidator); + } +}(this, function(SimpleReactValidator) { +"use strict"; + +var sr = { + accepted: 'Polje :attribute mora biti prihvaćeno.', + after: 'Polje :attribute mora biti nakon :date.', + after_or_equal: 'Polje :attribute mora biti nakon ili na :date.', + alpha: 'Polje :attribute može sadržati samo slova.', + alpha_space: 'Polje :attribute može sadržati samo slova i razmake.', + alpha_num: 'Polje :attribute može sadržati samo slova i brojeve.', + alpha_num_space: 'Polje :attribute može sadržati samo slova, brojeve i razmake.', + alpha_num_dash: 'Polje :attribute može sadržati samo slova, brojeve i crte.', + alpha_num_dash_space: 'Polje :attribute može sadržati samo slova, brojeve, crte i razmake.', + array: 'Polje :attribute mora biti niz.', + before: 'Polje :attribute mora biti pre :date.', + before_or_equal: 'Polje :attribute mora biti pre ili na :date.', + between: 'Polje :attribute mora biti između :min i :max:type.', + "boolean": 'Polje :attribute mora biti istinitosna vrednost.', + card_exp: 'Polje :attribute mora biti validan datum isteka.', + card_num: 'Polje :attribute mora biti validan broj kreditne kartice.', + currency: 'Polje :attribute mora biti validna valuta.', + date: 'Polje :attribute mora biti datum.', + date_equals: 'Polje :attribute mora biti na :date.', + email: 'Polje :attribute mora biti validna email adresa.', + "in": 'Izabrano polje :attribute mora biti :values.', + integer: 'Polje :attribute mora biti ceo broj.', + max: 'Polje :attribute ne sme biti veće od :max:type.', + min: 'Polje :attribute mora biti veće od :min:type.', + not_in: 'Izabrano polje :attribute ne sme biti :values.', + not_regex: 'Polje :attribute ne sme biti u određenom formatu.', + numeric: 'Polje :attribute mora biti broj.', + phone: 'Polje :attribute mora biti validan broj telefona.', + regex: 'Polje :attribute mora biti u određenom formatu.', + required: 'Polje :attribute je obavezno.', + size: 'Polje :attribute mora biti :size:type.', + string: 'Polje :attribute mora biti niska.', + "typeof": 'Polje :attribute nije ispravan tip :type.', + url: 'Polje :attribute mora biti URL.' +}; +SimpleReactValidator.addLocale('sr', sr); +return sr; +})); diff --git a/dist/locale/template-en.js b/dist/locale/template-en.js index 6522217..8eec83a 100644 --- a/dist/locale/template-en.js +++ b/dist/locale/template-en.js @@ -1,4 +1,4 @@ -// Simple React Validator v1.2.3 | Created By Dockwa | MIT License | 2017 - Present +// Simple React Validator v1.2.4 | Created By Dockwa | MIT License | 2017 - Present ;(function(root, factory) { if (typeof define === 'function' && define.amd) { define(['simple-react-validator'], factory); diff --git a/dist/simple-react-validator.js b/dist/simple-react-validator.js index 8e7601e..22630ce 100644 --- a/dist/simple-react-validator.js +++ b/dist/simple-react-validator.js @@ -1,4 +1,4 @@ -// Simple React Validator v1.2.3 | Created By Dockwa | MIT License | 2017 - Present +// Simple React Validator v1.2.4 | Created By Dockwa | MIT License | 2017 - Present ;(function(root, factory) { if (typeof define === 'function' && define.amd) { define(['react'], factory); @@ -14,7 +14,7 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } -function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } +function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } @@ -50,7 +50,9 @@ function () { _classCallCheck(this, SimpleReactValidator); _defineProperty(this, "showMessageFor", function (field) { - _this.visibleFields.push(field); + if (!_this.visibleFields.includes(field)) { + _this.visibleFields.push(field); + } _this.helpers.forceUpdateIfNeeded(); }); @@ -308,7 +310,7 @@ function () { "in": { message: 'The selected :attribute must be :values.', rule: function rule(val, params) { - return params.indexOf(val) > -1; + return params.includes(val); }, messageReplace: function messageReplace(message, params) { return message.replace(':values', _this.helpers.toSentence(params)); @@ -341,7 +343,7 @@ function () { not_in: { message: 'The selected :attribute must not be :values.', rule: function rule(val, params) { - return params.indexOf(val) === -1; + return !params.includes(val); }, messageReplace: function messageReplace(message, params) { return message.replace(':values', _this.helpers.toSentence(params)); @@ -561,7 +563,7 @@ function () { return SimpleReactValidator; }(); -_defineProperty(SimpleReactValidator, "version", '1.2.0'); +_defineProperty(SimpleReactValidator, "version", '1.2.4'); _defineProperty(SimpleReactValidator, "locales", { 'en': {} diff --git a/dist/simple-react-validator.min.js b/dist/simple-react-validator.min.js index fe71def..1962474 100644 --- a/dist/simple-react-validator.min.js +++ b/dist/simple-react-validator.min.js @@ -1,2 +1,2 @@ -// Simple React Validator v1.2.3 | Created By Dockwa | MIT License | 2017 - Present -!function(e,t){"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?module.exports=t(require("react")):e.SimpleReactValidator=t(e.React)}(this,function(n){"use strict";function g(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=[],s=!0,n=!1,a=void 0;try{for(var i,u=e[Symbol.iterator]();!(s=(i=u.next()).done)&&(r.push(i.value),!t||r.length!==t);s=!0);}catch(e){n=!0,a=e}finally{try{s||null==u.return||u.return()}finally{if(n)throw a}}return r}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function s(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,s)}return r}function b(t){for(var e=1;e=parseFloat(t[0])&&r.helpers.size(e,t[2])<=parseFloat(t[1])},messageReplace:function(e,t){return e.replace(":min",t[0]).replace(":max",t[1]).replace(":type",r.helpers.sizeText(t[2]))}},boolean:{message:"The :attribute must be a boolean.",rule:function(e){return!1===e||!0===e}},card_exp:{message:"The :attribute must be a valid expiration date.",rule:function(e){return r.helpers.testRegex(e,/^(([0]?[1-9]{1})|([1]{1}[0-2]{1}))\s?\/\s?(\d{2}|\d{4})$/)}},card_num:{message:"The :attribute must be a valid credit card number.",rule:function(e){return r.helpers.testRegex(e,/^\d{4}\s?\d{4,6}\s?\d{4,5}\s?\d{0,8}$/)}},currency:{message:"The :attribute must be a valid currency.",rule:function(e){return r.helpers.testRegex(e,/^\$?(\d{1,3})(\,?\d{3})*\.?\d{0,2}$/)}},date:{message:"The :attribute must be a date.",rule:function(e){return r.helpers.momentInstalled()&&moment.isMoment(e)}},date_equals:{message:"The :attribute must be on :date.",rule:function(e,t){return r.helpers.momentInstalled()&&moment.isMoment(e)&&e.isSame(t[0],"day")},messageReplace:function(e,t){return e.replace(":date",t[0].format("MM/DD/YYYY"))}},email:{message:"The :attribute must be a valid email address.",rule:function(e){return r.helpers.testRegex(e,/^[A-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i)}},in:{message:"The selected :attribute must be :values.",rule:function(e,t){return-1=parseFloat(t[0])},messageReplace:function(e,t){return e.replace(":min",t[0]).replace(":type",r.helpers.sizeText(t[1]))}},not_in:{message:"The selected :attribute must not be :values.",rule:function(e,t){return-1===t.indexOf(e)},messageReplace:function(e,t){return e.replace(":values",r.helpers.toSentence(t))}},not_regex:{message:"The :attribute must not match the required pattern.",rule:function(e,t){return!r.helpers.testRegex(e,"string"==typeof t[0]||t[0]instanceof String?new RegExp(t[0]):t[0])}},numeric:{message:"The :attribute must be a number.",rule:function(e){return r.helpers.numeric(e)}},phone:{message:"The :attribute must be a valid phone number.",rule:function(e){return r.helpers.testRegex(e,/^(\+?\d{0,4})?\s?-?\s?(\(?\d{3}\)?)\s?-?\s?(\(?\d{3}\)?)\s?-?\s?(\(?\d{4}\)?)?$/)}},regex:{message:"The :attribute must match the required pattern.",rule:function(e,t){return r.helpers.testRegex(e,"string"==typeof t[0]||t[0]instanceof String?new RegExp(t[0]):t[0])}},required:{message:"The :attribute field is required.",rule:function(e){return!r.helpers.isBlank(e)},required:!0},size:{message:"The :attribute must be :size:type.",rule:function(e,t){return r.helpers.size(e,t[1])==parseFloat(t[0])},messageReplace:function(e,t){return e.replace(":size",t[0]).replace(":type",r.helpers.sizeText(t[1]))}},string:{message:"The :attribute must be a string.",rule:function(e){return a(e)===a("string")}},typeof:{message:"The :attribute is not the correct type of :type.",rule:function(e,t){return a(e)===a(t[0])},messageReplace:function(e,t){return e.replace(":type",a(t[0]))}},url:{message:"The :attribute must be a url.",rule:function(e){return r.helpers.testRegex(e,/^(https?|ftp):\/\/(-\.)?([^\s/?\.#-]+\.?)+(\/[^\s]*)?$/i)}}},e.validators||{}),s.locales.hasOwnProperty(e.locale)||console.warn("Locale not found! Make sure it is spelled correctly and the locale file is loaded.");var t=s.locales[e.locale]||{};Object.keys(this.rules).forEach(function(e){r.rules[e].message=t[e]||r.rules[e].message}),this.messages=e.messages||{},this.className=e.className,this.autoForceUpdate=e.autoForceUpdate||!1,!1===e.element?this.element=function(e){return e}:e.hasOwnProperty("element")?this.element=e.element:"object"===("undefined"==typeof navigator?"undefined":a(navigator))&&"ReactNative"===navigator.product?this.element=function(e){return e}:this.element=function(e,t){return n.createElement("div",{className:t||r.className||"srv-validation-message"},e)}}return e(s,null,[{key:"addLocale",value:function(e,t){this.locales[e]=t}}]),e(s,[{key:"getErrorMessages",value:function(){return this.errorMessages}},{key:"showMessages",value:function(){this.messagesShown=!0,this.helpers.forceUpdateIfNeeded()}},{key:"hideMessages",value:function(){this.messagesShown=!1,this.helpers.forceUpdateIfNeeded()}},{key:"allValid",value:function(){for(var e in this.fields)if(!1===this.fieldValid(e))return!1;return!0}},{key:"fieldValid",value:function(e){return this.fields.hasOwnProperty(e)&&!0===this.fields[e]}},{key:"purgeFields",value:function(){this.fields={},this.errorMessages={}}},{key:"messageWhenPresent",value:function(e){var t=1=parseFloat(t[0])&&r.helpers.size(e,t[2])<=parseFloat(t[1])},messageReplace:function(e,t){return e.replace(":min",t[0]).replace(":max",t[1]).replace(":type",r.helpers.sizeText(t[2]))}},boolean:{message:"The :attribute must be a boolean.",rule:function(e){return!1===e||!0===e}},card_exp:{message:"The :attribute must be a valid expiration date.",rule:function(e){return r.helpers.testRegex(e,/^(([0]?[1-9]{1})|([1]{1}[0-2]{1}))\s?\/\s?(\d{2}|\d{4})$/)}},card_num:{message:"The :attribute must be a valid credit card number.",rule:function(e){return r.helpers.testRegex(e,/^\d{4}\s?\d{4,6}\s?\d{4,5}\s?\d{0,8}$/)}},currency:{message:"The :attribute must be a valid currency.",rule:function(e){return r.helpers.testRegex(e,/^\$?(\d{1,3})(\,?\d{3})*\.?\d{0,2}$/)}},date:{message:"The :attribute must be a date.",rule:function(e){return r.helpers.momentInstalled()&&moment.isMoment(e)}},date_equals:{message:"The :attribute must be on :date.",rule:function(e,t){return r.helpers.momentInstalled()&&moment.isMoment(e)&&e.isSame(t[0],"day")},messageReplace:function(e,t){return e.replace(":date",t[0].format("MM/DD/YYYY"))}},email:{message:"The :attribute must be a valid email address.",rule:function(e){return r.helpers.testRegex(e,/^[A-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i)}},in:{message:"The selected :attribute must be :values.",rule:function(e,t){return t.includes(e)},messageReplace:function(e,t){return e.replace(":values",r.helpers.toSentence(t))}},integer:{message:"The :attribute must be an integer.",rule:function(e){return r.helpers.testRegex(e,/^\d*$/)}},max:{message:"The :attribute may not be greater than :max:type.",rule:function(e,t){return r.helpers.size(e,t[1])<=parseFloat(t[0])},messageReplace:function(e,t){return e.replace(":max",t[0]).replace(":type",r.helpers.sizeText(t[1]))}},min:{message:"The :attribute must be at least :min:type.",rule:function(e,t){return r.helpers.size(e,t[1])>=parseFloat(t[0])},messageReplace:function(e,t){return e.replace(":min",t[0]).replace(":type",r.helpers.sizeText(t[1]))}},not_in:{message:"The selected :attribute must not be :values.",rule:function(e,t){return!t.includes(e)},messageReplace:function(e,t){return e.replace(":values",r.helpers.toSentence(t))}},not_regex:{message:"The :attribute must not match the required pattern.",rule:function(e,t){return!r.helpers.testRegex(e,"string"==typeof t[0]||t[0]instanceof String?new RegExp(t[0]):t[0])}},numeric:{message:"The :attribute must be a number.",rule:function(e){return r.helpers.numeric(e)}},phone:{message:"The :attribute must be a valid phone number.",rule:function(e){return r.helpers.testRegex(e,/^(\+?\d{0,4})?\s?-?\s?(\(?\d{3}\)?)\s?-?\s?(\(?\d{3}\)?)\s?-?\s?(\(?\d{4}\)?)?$/)}},regex:{message:"The :attribute must match the required pattern.",rule:function(e,t){return r.helpers.testRegex(e,"string"==typeof t[0]||t[0]instanceof String?new RegExp(t[0]):t[0])}},required:{message:"The :attribute field is required.",rule:function(e){return!r.helpers.isBlank(e)},required:!0},size:{message:"The :attribute must be :size:type.",rule:function(e,t){return r.helpers.size(e,t[1])==parseFloat(t[0])},messageReplace:function(e,t){return e.replace(":size",t[0]).replace(":type",r.helpers.sizeText(t[1]))}},string:{message:"The :attribute must be a string.",rule:function(e){return a(e)===a("string")}},typeof:{message:"The :attribute is not the correct type of :type.",rule:function(e,t){return a(e)===a(t[0])},messageReplace:function(e,t){return e.replace(":type",a(t[0]))}},url:{message:"The :attribute must be a url.",rule:function(e){return r.helpers.testRegex(e,/^(https?|ftp):\/\/(-\.)?([^\s/?\.#-]+\.?)+(\/[^\s]*)?$/i)}}},e.validators||{}),s.locales.hasOwnProperty(e.locale)||console.warn("Locale not found! Make sure it is spelled correctly and the locale file is loaded.");var t=s.locales[e.locale]||{};Object.keys(this.rules).forEach(function(e){r.rules[e].message=t[e]||r.rules[e].message}),this.messages=e.messages||{},this.className=e.className,this.autoForceUpdate=e.autoForceUpdate||!1,!1===e.element?this.element=function(e){return e}:e.hasOwnProperty("element")?this.element=e.element:"object"===("undefined"==typeof navigator?"undefined":a(navigator))&&"ReactNative"===navigator.product?this.element=function(e){return e}:this.element=function(e,t){return n.createElement("div",{className:t||r.className||"srv-validation-message"},e)}}return e(s,null,[{key:"addLocale",value:function(e,t){this.locales[e]=t}}]),e(s,[{key:"getErrorMessages",value:function(){return this.errorMessages}},{key:"showMessages",value:function(){this.messagesShown=!0,this.helpers.forceUpdateIfNeeded()}},{key:"hideMessages",value:function(){this.messagesShown=!1,this.helpers.forceUpdateIfNeeded()}},{key:"allValid",value:function(){for(var e in this.fields)if(!1===this.fieldValid(e))return!1;return!0}},{key:"fieldValid",value:function(e){return this.fields.hasOwnProperty(e)&&!0===this.fields[e]}},{key:"purgeFields",value:function(){this.fields={},this.errorMessages={}}},{key:"messageWhenPresent",value:function(e){var t=1 this.helpers.momentInstalled() && moment.isMoment(val)}, date_equals : {message: 'The :attribute must be on :date.', rule: (val, params) => this.helpers.momentInstalled() && moment.isMoment(val) && val.isSame(params[0], 'day'), messageReplace: (message, params) => message.replace(':date', params[0].format('MM/DD/YYYY'))}, email : {message: 'The :attribute must be a valid email address.', rule: val => this.helpers.testRegex(val,/^[A-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i)}, - in : {message: 'The selected :attribute must be :values.', rule: (val, params) => params.indexOf(val) > -1, messageReplace: (message, params) => message.replace(':values', this.helpers.toSentence(params))}, + in : {message: 'The selected :attribute must be :values.', rule: (val, params) => params.includes(val), messageReplace: (message, params) => message.replace(':values', this.helpers.toSentence(params))}, integer : {message: 'The :attribute must be an integer.', rule: val => this.helpers.testRegex(val,/^\d*$/)}, max : {message: 'The :attribute may not be greater than :max:type.', rule: (val, params) => this.helpers.size(val, params[1]) <= parseFloat(params[0]), messageReplace: (message, params) => message.replace(':max', params[0]).replace(':type', this.helpers.sizeText(params[1]))}, min : {message: 'The :attribute must be at least :min:type.', rule: (val, params) => this.helpers.size(val, params[1]) >= parseFloat(params[0]), messageReplace: (message, params) => message.replace(':min', params[0]).replace(':type', this.helpers.sizeText(params[1]))}, - not_in : {message: 'The selected :attribute must not be :values.', rule: (val, params) => params.indexOf(val) === -1, messageReplace: (message, params) => message.replace(':values', this.helpers.toSentence(params))}, + not_in : {message: 'The selected :attribute must not be :values.', rule: (val, params) => !params.includes(val), messageReplace: (message, params) => message.replace(':values', this.helpers.toSentence(params))}, not_regex : {message: 'The :attribute must not match the required pattern.', rule: (val, params) => !this.helpers.testRegex(val, typeof params[0] === 'string' || params[0] instanceof String ? new RegExp(params[0]) : params[0])}, numeric : {message: 'The :attribute must be a number.', rule: val => this.helpers.numeric(val)}, phone : {message: 'The :attribute must be a valid phone number.', rule: val => this.helpers.testRegex(val,/^(\+?\d{0,4})?\s?-?\s?(\(?\d{3}\)?)\s?-?\s?(\(?\d{3}\)?)\s?-?\s?(\(?\d{4}\)?)?$/)}, @@ -90,7 +90,9 @@ class SimpleReactValidator { } showMessageFor = field => { - this.visibleFields.push(field); + if (!this.visibleFields.includes(field)) { + this.visibleFields.push(field); + } this.helpers.forceUpdateIfNeeded(); }