aw-front-helpers 2.3.9 → 2.3.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,11 +13,13 @@ const defaultOptions = {
13
13
  classIsError: 'is-error',
14
14
  animateToFirstError: true,
15
15
  i18n: {
16
- email: Translator ? Translator.trans('form_errors.email') : 'Merci de renseigner un email valide.',
16
+ required: Translator ? Translator.trans('form_errors.pattern') : 'Ce champs est obligatoire',
17
17
  same: Translator ? Translator.trans('form_errors.same') : 'Les champs ne correspondent pas.',
18
+ email: Translator ? Translator.trans('form_errors.email') : 'Merci de renseigner un email valide.',
18
19
  empty: Translator ? Translator.trans('form_errors.empty') : 'Ce champs est obligatoire.',
19
20
  checkbox: Translator ? Translator.trans('form_errors.checkbox') : 'Veuillez accepter les conditions.',
20
- radio: Translator ? Translator.trans('form_errors.radio') : 'Veuillez sélectionner au moins un choix.'
21
+ radio: Translator ? Translator.trans('form_errors.radio') : 'Veuillez sélectionner au moins un choix.',
22
+ pattern: Translator ? Translator.trans('form_errors.pattern') : 'La donnée saisie ne respecte pas les règles énoncées.',
21
23
  }
22
24
  };
23
25
 
@@ -154,6 +156,14 @@ class FormControl {
154
156
  validate = false;
155
157
  this.setError(el, this._options.i18n.same);
156
158
  }
159
+ if ( el.getAttribute('pattern') && el.value !== '') {
160
+ const pattern = el.getAttribute('pattern');
161
+ const rgx = new RegExp(pattern);
162
+ if(rgx.test(el.value)){
163
+ validate = false;
164
+ this.setError(el, this._options.i18n.pattern);
165
+ }
166
+ }
157
167
  if (el.getAttribute('required') !== null) {
158
168
  if (el.getAttribute('type') === 'radio') {
159
169
  let isChecked = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aw-front-helpers",
3
- "version": "2.3.9",
3
+ "version": "2.3.10",
4
4
  "description": "Assets helpers for projects",
5
5
  "author": "Yoann Le Poupon",
6
6
  "license": "ISC",