aw-front-helpers 2.5.23 → 2.5.24

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.
@@ -112,6 +112,25 @@ export default class FormControl {
112
112
  this._formGrabDom();
113
113
  }
114
114
 
115
+ addControl(el, controlName, test, errorMessage) {
116
+ if(!el) return
117
+ el.specialControls = el.specialControls || {};
118
+ el.specialControls[controlName] = {
119
+ isValid: () => test(el.value), errorMessage
120
+ }
121
+ }
122
+
123
+ checkError(el) {
124
+ this._checkError(el);
125
+ }
126
+
127
+ removeControl(el, controlName) {
128
+ if(!el) return
129
+ if(el.specialControls && el.specialControls[controlName]) {
130
+ delete el.specialControls[controlName];
131
+ }
132
+ }
133
+
115
134
  removeErrors(el = null) {
116
135
  this._removeError(el);
117
136
  }
@@ -248,7 +267,14 @@ export default class FormControl {
248
267
  invalid = true;
249
268
  this.setError(el, this._options.i18n.same);
250
269
  }
251
-
270
+ if( el.specialControls ) {
271
+ for( let key in el.specialControls ) {
272
+ if( !el.specialControls[key].isValid() ) {
273
+ invalid = true;
274
+ this.setError(el, el.specialControls[key].errorMessage);
275
+ }
276
+ }
277
+ }
252
278
  return invalid;
253
279
  }
254
280
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aw-front-helpers",
3
- "version": "2.5.23",
3
+ "version": "2.5.24",
4
4
  "description": "Assets helpers for projects",
5
5
  "author": "Yoann Le Poupon",
6
6
  "license": "ISC",