@nuka9510/simple-validation 1.3.0 → 1.4.1

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.
package/dist/js/index.js CHANGED
@@ -60,38 +60,46 @@ __webpack_require__.r(__webpack_exports__);
60
60
  * Validation Check를 위한 객체
61
61
  */
62
62
  class Validation {
63
- /** 결과 값 객체 */
64
63
  result;
65
- /** validation check할 Element를 담는 객체 */
66
- #el;
67
- /** validation check할 radio Element를 담는 객체 */
64
+ #input;
65
+ #date;
66
+ #checkbox;
68
67
  #radio;
69
- /** validation check에 사용할 정규식을 담은 객체 */
70
68
  #regex;
71
69
  /**
72
70
  * Validation Check를 위한 객체
73
71
  *
74
72
  * ```
75
73
  * <form name="form">
76
- * <input type="text" name="text" data-sv-pattern="password" data-sv-input-name="비밀번호" minlength="0" maxlength="10">
77
- * <input type="text" name="text" data-sv-pattern="password" minlength="0" maxlength="10" required="비밀번호">
78
- * <input type="date" name="sdate1" data-sv-date="date1" data-sv-date-state="S" data-sv-input-name="검색일1">
79
- * <input type="date" name="edate1" data-sv-date="date1" data-sv-date-state="E" data-sv-input-name="검색일1">
80
- * <input type="date" name="sdate2" data-sv-date="date2" data-sv-date-state="S" required="검색일2">
81
- * <input type="date" name="edate2" data-sv-date="date2" data-sv-date-state="E" required="검색일2">
74
+ * <input type="text" name="text" minlength="0" maxlength="10" data-sv-pattern="password" data-sv-input="비밀번호">
75
+ * <input type="text" name="text" minlength="0" maxlength="10" data-sv-pattern="password" required="비밀번호">
76
+ *
77
+ * <input type="date" name="sdate1" data-sv-name="date1" data-sv-state="S" data-sv-date="검색일1">
78
+ * <input type="date" name="edate1" data-sv-name="date1" data-sv-state="E" data-sv-date="검색일1">
79
+ * <input type="date" name="sdate2" data-sv-name="date2" data-sv-state="S" required="검색일2">
80
+ * <input type="date" name="edate2" data-sv-name="date2" data-sv-state="E" required="검색일2">
81
+ *
82
+ * <input type="checkbox" data-sv-name="checkbox1" data-sv-state="A" required="옵션">
83
+ * <input type="checkbox" data-sv-name="checkbox1" data-sv-state="A" required="옵션">
84
+ * <input type="checkbox" name="checkbox2" data-sv-state="B" required="옵션">
85
+ * <input type="checkbox" name="checkbox2" data-sv-state="B" required="옵션">
86
+ *
87
+ * <input type="radio" data-sv-name="radio1" required="옵션">
88
+ * <input type="radio" data-sv-name="radio1" required="옵션">
89
+ * <input type="radio" name="radio2" required="옵션">
90
+ * <input type="radio" name="radio2" required="옵션">
82
91
  * </form>
83
92
  * <script type="importmap">
84
93
  * {
85
94
  * "imports": {
86
- * "@nuka9510/js-util": "https://cdn.jsdelivr.net/npm/@nuka9510/js-util/dist/index.js",
87
- * "@nuka9510/simple-validation": "https://cdn.jsdelivr.net/npm/@nuka9510/simple-validation/dist/index.js"
95
+ * "@nuka9510/simple-validation": "https://cdn.jsdelivr.net/npm/@nuka9510/simple-validation/dist/esm/index.min.mjs"
88
96
  * }
89
97
  * }
90
98
  * </script>
91
99
  * <script type="module">
92
- * import { SValidation } from "@nuka9510/simple-validation";
100
+ * import { Validation } from "@nuka9510/simple-validation";
93
101
  *
94
- * const validation = new SValidation({regex: {password: /^[\S!?@#$%^&*():;+-=~{}<>\_\[\]\|\\\"\'\,\.\/\`]{6,10}$/}});
102
+ * const validation = new Validation({regex: {password: /^[\S!?@#$%^&*():;+-=~{}<>\_\[\]\|\\\"\'\,\.\/\`]{6,10}$/}});
95
103
  *
96
104
  * validation.run(form);
97
105
  *
@@ -104,16 +112,16 @@ class Validation {
104
112
  * </script>
105
113
  * ```
106
114
  */
107
- constructor(config) { this.init(config); }
108
- /** 객체 초기화 */
109
- init(
110
- /** validation 초기화를 위한 객체 */ config = null) {
115
+ constructor(
116
+ /** validation 초기화를 위한 객체 */ config) { this.#init(config); }
117
+ #init(config = null) {
111
118
  this.#resultInit();
112
- this.#elInit();
119
+ this.#inputInit();
120
+ this.#dateInit();
121
+ this.#checkboxInit();
113
122
  this.#radioInit();
114
123
  this.#regexInit(config?.regex);
115
124
  }
116
- /** 결과 값 초기화 */
117
125
  #resultInit() {
118
126
  this.result = {
119
127
  flag: true,
@@ -122,235 +130,282 @@ class Validation {
122
130
  phase: _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].INIT
123
131
  };
124
132
  }
125
- /** validation check할 Element를 담는 객체 초기화 */
126
- #elInit() { this.#el = {}; }
127
- /** validation check할 radio Element를 담는 객체 초기화 */
133
+ #inputInit() { this.#input = []; }
134
+ #dateInit() { this.#date = {}; }
135
+ #checkboxInit() { this.#checkbox = {}; }
128
136
  #radioInit() { this.#radio = {}; }
129
- /** validation check에 사용할 정규식을 담은 객체 초기화 */
130
137
  #regexInit(regex = null) {
131
138
  this.#regex = (!_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(regex) &&
132
139
  _nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.isObject(regex))
133
140
  ? {
134
- ...this.#regex,
141
+ ...(this.#regex ?? {}),
135
142
  ...regex
136
143
  }
137
- : { ...this.#regex };
144
+ : { ...(this.#regex ?? {}) };
138
145
  }
139
- /** el 있는 Element들을 required check한다. */
140
- #required(el) {
141
- const required = el.getAttribute('required');
142
- if (!_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(required)) {
143
- if (el.type == 'radio') {
146
+ #setEl(el) {
147
+ const type = el.getAttribute('type');
148
+ switch (type) {
149
+ case 'date':
150
+ case 'time':
151
+ case 'datetime-local':
152
+ case 'month':
153
+ case 'week':
154
+ this.#setDate(el);
155
+ break;
156
+ case 'checkbox':
157
+ this.#setCheckbox(el);
158
+ break;
159
+ case 'radio':
144
160
  this.#setRadio(el);
145
- }
146
- else if (_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(el.value)) {
147
- this.result.flag = false;
148
- this.result.alertMsg = `'${required}'을/를 입력해 주세요.`;
149
- this.result.el = el;
150
- this.result.phase = _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].REQUIRED;
151
- }
152
- }
153
- }
154
- /** radio에 있는 Element들을 required check한다. */
155
- #requiredRadio() {
156
- for (const i in this.#radio) {
157
- const el = this.#radio[i][0], flag = this.#radio[i].some((...arg) => arg[0].checked);
158
- if (!flag) {
159
- this.result.flag = false;
160
- this.result.alertMsg = `'${i}'을/를 선택해주세요.`;
161
- this.result.el = el;
162
- this.result.phase = _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].REQUIRED;
163
161
  break;
164
- }
162
+ default:
163
+ this.#setInput(el);
164
+ break;
165
165
  }
166
166
  }
167
- /** el Element를 담는다. */
168
- #setEl(el) {
169
- const pattern = el.dataset['svPattern'], date = el.dataset['svDate'];
170
- if (!_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(pattern)) {
171
- if (_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(this.#el.el)) {
172
- this.#el.el = [];
173
- }
174
- this.#el.el?.push(el);
175
- }
176
- if (!_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(date)) {
177
- const state = el.dataset['svDateState'];
167
+ #setInput(el) { this.#input.push(el); }
168
+ #setDate(el) {
169
+ const name = el.getAttribute('data-sv-name');
170
+ if (!_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(name)) {
171
+ const state = el.getAttribute('data-sv-state');
178
172
  switch (state) {
179
173
  case 'S':
180
174
  case 'E':
181
- if (_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(this.#el.date)) {
182
- this.#el.date = {};
183
- }
184
- if (_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(this.#el.date[date])) {
185
- this.#el.date[date] = {};
175
+ if (_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(this.#date[name])) {
176
+ this.#date[name] = {};
186
177
  }
187
- this.#el.date[date][state] = el;
178
+ this.#date[name][state] = el;
179
+ break;
180
+ default:
181
+ this.#input.push(el);
188
182
  break;
189
183
  }
190
184
  }
185
+ else {
186
+ this.#input.push(el);
187
+ }
188
+ }
189
+ #setCheckbox(el) {
190
+ const name = el.getAttribute('name') || el.getAttribute('data-sv-name');
191
+ if (!_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(name)) {
192
+ if (_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(this.#checkbox[name])) {
193
+ this.#checkbox[name] = [];
194
+ }
195
+ this.#checkbox[name].push(el);
196
+ }
191
197
  }
192
- /** `#radio`에 type이 'radio'인 Element를 담는다. */
193
198
  #setRadio(el) {
194
- const required = el.getAttribute('required');
195
- if (!_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(required)) {
196
- if (_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(this.#radio[required])) {
197
- this.#radio[required] = [el];
199
+ const name = el.getAttribute('name') || el.getAttribute('data-sv-name');
200
+ if (!_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(name)) {
201
+ if (_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(this.#radio[name])) {
202
+ this.#radio[name] = [];
198
203
  }
199
- else {
200
- this.#radio[required].push(el);
204
+ this.#radio[name].push(el);
205
+ }
206
+ }
207
+ #requiredEl() {
208
+ if (this.result.flag) {
209
+ this.#requiredInput();
210
+ }
211
+ if (this.result.flag) {
212
+ this.#requiredDate();
213
+ }
214
+ if (this.result.flag) {
215
+ this.#requiredCheckbox();
216
+ }
217
+ if (this.result.flag) {
218
+ this.#requiredRadio();
219
+ }
220
+ }
221
+ #requiredInput() {
222
+ for (const input of this.#input) {
223
+ const required = input.getAttribute('required');
224
+ if (!_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(required) &&
225
+ _nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(input.value)) {
226
+ this.result = {
227
+ flag: false,
228
+ alertMsg: `'${required}'을/를 입력해 주세요.`,
229
+ el: input,
230
+ phase: _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].REQUIRED
231
+ };
232
+ break;
201
233
  }
202
234
  }
203
235
  }
204
- /**
205
- * Element들을 validation check 한다.
206
- * ```
207
- * -----------------------
208
- * date : isDate
209
- * -----------------------
210
- * el : isPattern
211
- * ```
212
- */
213
- #match() {
214
- for (const i in this.#el) {
215
- if (this.result.flag) {
216
- switch (i) {
217
- case 'date':
218
- this.#isDate(this.#el[i]);
219
- break;
220
- case 'el':
221
- this.#isPattern(this.#el[i]);
222
- break;
236
+ #requiredDate() {
237
+ for (const name in this.#date) {
238
+ for (const state in this.#date[name]) {
239
+ const date = this.#date[name][state], required = date.getAttribute('required');
240
+ if (!_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(required) &&
241
+ _nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(date.value)) {
242
+ this.result = {
243
+ flag: false,
244
+ alertMsg: `'${required}'을/를 입력해 주세요.`,
245
+ el: date,
246
+ phase: _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].REQUIRED
247
+ };
248
+ break;
223
249
  }
224
250
  }
225
- else {
251
+ }
252
+ }
253
+ #requiredCheckbox() {
254
+ for (const name in this.#checkbox) {
255
+ const checkboxList = this.#checkbox[name].filter((...arg) => !_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(arg[0].getAttribute('required'))), checkboxAList = checkboxList.filter((...arg) => (arg[0].getAttribute('data-sv-state') || 'A') == 'A'), checkboxBList = checkboxList.filter((...arg) => (arg[0].getAttribute('data-sv-state') || 'A') == 'B');
256
+ let checkbox = null;
257
+ if (_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(checkbox) &&
258
+ !_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(checkboxAList) &&
259
+ checkboxAList.some((...arg) => !arg[0].checked)) {
260
+ checkbox = checkboxAList.find((...arg) => !arg[0].checked);
261
+ }
262
+ if (_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(checkbox) &&
263
+ !_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(checkboxBList) &&
264
+ checkboxBList.every((...arg) => !arg[0].checked)) {
265
+ checkbox = checkboxBList.find((...arg) => !arg[0].checked);
266
+ }
267
+ if (!_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(checkbox)) {
268
+ const required = checkbox.getAttribute('required');
269
+ this.result = {
270
+ flag: false,
271
+ alertMsg: `'${required}'을/를 선택해주세요.`,
272
+ el: checkbox,
273
+ phase: _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].REQUIRED
274
+ };
226
275
  break;
227
276
  }
228
277
  }
229
278
  }
230
- /** date check */
231
- #isDate(el) {
232
- for (const i in el) {
233
- if (this.result.flag) {
234
- const sdate = el[i].S.value, edate = el[i].E.value;
235
- if (!_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(sdate) &&
236
- !_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(edate)) {
237
- const inputName = el[i].S.dataset['svInputName'] ||
238
- el[i].E.dataset['svInputName'], required = el[i].S.getAttribute('required') ||
239
- el[i].E.getAttribute('required');
240
- if ((new Date(sdate)).getTime() > (new Date(edate)).getTime()) {
241
- this.result.flag = false;
242
- this.result.alertMsg = `'${inputName || required}'의 시작일이 종료일 보다 늦습니다.`;
243
- this.result.el = el[i].S;
244
- this.result.phase = _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].MATCH;
245
- }
246
- }
247
- }
248
- else {
279
+ #requiredRadio() {
280
+ for (const name in this.#radio) {
281
+ const radioList = this.#radio[name].filter((...arg) => !_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(arg[0].getAttribute('required')));
282
+ if (!_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(radioList) &&
283
+ radioList.every((...arg) => !arg[0].checked)) {
284
+ const radio = radioList.find((...arg) => !arg[0].checked), required = radio.getAttribute('required');
285
+ this.result = {
286
+ flag: false,
287
+ alertMsg: `'${required}'을/를 선택해주세요.`,
288
+ el: radio,
289
+ phase: _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].REQUIRED
290
+ };
249
291
  break;
250
292
  }
251
293
  }
252
294
  }
253
- /** regex check */
254
- #isPattern(el) {
255
- if (Array.isArray(el)) {
256
- for (const i of el) {
257
- const pattern = i.dataset['svPattern'], inputName = i.dataset['svInputName'], required = i.getAttribute('required'), val = i.value;
258
- if (Object.keys(this.#regex).includes(pattern)) {
259
- if (!_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(val) &&
260
- !this.#regex[pattern].test(val)) {
261
- this.result.flag = false;
262
- this.result.alertMsg = `'${inputName || required}'의 형식이 올바르지 않습니다.`;
263
- this.result.el = i;
264
- this.result.phase = _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].MATCH;
295
+ #length() {
296
+ for (const input of this.#input) {
297
+ const input_ = input.getAttribute('data-sv-input') || input.getAttribute('required'), length = input.value.length;
298
+ if (!(input instanceof HTMLSelectElement)) {
299
+ if (input.minLength >= 0 &&
300
+ input.maxLength >= 0) {
301
+ if (length < input.minLength ||
302
+ length > input.maxLength) {
303
+ this.result = {
304
+ flag: false,
305
+ alertMsg: `'${input_}'은/는 ${input.minLength}~${input.maxLength}자 이내로 입력해주세요.`,
306
+ el: input,
307
+ phase: _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].LENGTH
308
+ };
309
+ break;
310
+ }
311
+ }
312
+ else if (input.minLength >= 0 &&
313
+ input.maxLength < 0) {
314
+ if (length < input.minLength) {
315
+ this.result = {
316
+ flag: false,
317
+ alertMsg: `'${input_}'은/는 ${input.minLength}자 이상으로 입력해주세요.`,
318
+ el: input,
319
+ phase: _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].LENGTH
320
+ };
321
+ break;
322
+ }
323
+ }
324
+ else if (input.minLength < 0 &&
325
+ input.maxLength >= 0) {
326
+ if (length > input.maxLength) {
327
+ this.result = {
328
+ flag: false,
329
+ alertMsg: `'${input_}'은/는 ${input.maxLength}자 이하로 입력해주세요.`,
330
+ el: input,
331
+ phase: _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].LENGTH
332
+ };
265
333
  break;
266
334
  }
267
335
  }
268
336
  }
269
337
  }
270
- else {
271
- const pattern = el.dataset['svPattern'], inputName = el.dataset['svInputName'], required = el.getAttribute('required'), val = el.value;
272
- if (Object.keys(this.#regex).includes(pattern)) {
273
- if (!_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(val) &&
274
- !this.#regex[pattern].test(val)) {
275
- this.result.flag = false;
276
- this.result.alertMsg = `'${inputName || required}'의 형식이 올바르지 않습니다.`;
277
- this.result.el = el;
278
- this.result.phase = _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].MATCH;
338
+ }
339
+ #match(regex) {
340
+ if (this.result.flag) {
341
+ this.#isPattern(regex);
342
+ }
343
+ if (this.result.flag) {
344
+ this.#isDate();
345
+ }
346
+ }
347
+ #isPattern(regex = null) {
348
+ const regex_ = {
349
+ ...this.#regex,
350
+ ...(regex ?? {})
351
+ };
352
+ for (const input of this.#input) {
353
+ const pattern = input.getAttribute('data-sv-pattern');
354
+ if (Object.keys(regex_).includes(pattern)) {
355
+ const input_ = input.getAttribute('data-sv-input') || input.getAttribute('required'), value = input.value;
356
+ if (!_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(value) &&
357
+ !regex_[pattern].test(value)) {
358
+ this.result = {
359
+ flag: false,
360
+ alertMsg: `'${input_}'의 형식이 올바르지 않습니다.`,
361
+ el: input,
362
+ phase: _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].MATCH
363
+ };
364
+ break;
279
365
  }
280
366
  }
281
367
  }
282
368
  }
283
- /** Element value의 length를 check 한다. */
284
- #length() {
285
- for (const i in this.#el) {
286
- if (i == 'el' &&
287
- this.result.flag) {
288
- for (const j of this.#el[i]) {
289
- const inputName = j.dataset['svInputName'], required = j.getAttribute('required'), val = j.value.length;
290
- if (!(j instanceof HTMLSelectElement)) {
291
- if (j.minLength >= 0 &&
292
- j.maxLength >= 0) {
293
- if (val < j.minLength ||
294
- val > j.maxLength) {
295
- this.result.flag = false;
296
- this.result.alertMsg = `'${inputName || required}'은/는 ${j.minLength}~${j.maxLength}자 이내로 입력해주세요.`;
297
- this.result.el = j;
298
- this.result.phase = _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].LENGTH;
299
- break;
300
- }
301
- }
302
- else if (j.minLength >= 0 &&
303
- j.maxLength < 0) {
304
- if (val < j.minLength) {
305
- this.result.flag = false;
306
- this.result.alertMsg = `'${inputName || required}'은/는 ${j.minLength}자 이상으로 입력해주세요.`;
307
- this.result.el = j;
308
- this.result.phase = _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].LENGTH;
309
- break;
310
- }
311
- }
312
- else if (j.minLength < 0 &&
313
- j.maxLength >= 0) {
314
- if (val > j.maxLength) {
315
- this.result.flag = false;
316
- this.result.alertMsg = `'${inputName || required}'은/는 ${j.maxLength}자 이하로 입력해주세요.`;
317
- this.result.el = j;
318
- this.result.phase = _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].LENGTH;
319
- break;
320
- }
321
- }
322
- }
369
+ #isDate() {
370
+ for (const name in this.#date) {
371
+ const date = this.#date[name], sdate = date.S, edate = date.E;
372
+ if (!_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(sdate) &&
373
+ !_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(edate)) {
374
+ const input_ = sdate.getAttribute('data-sv-date') ||
375
+ edate.getAttribute('data-sv-date') ||
376
+ sdate.getAttribute('required') ||
377
+ edate.getAttribute('required');
378
+ if (sdate.valueAsNumber > edate.valueAsNumber) {
379
+ this.result = {
380
+ flag: false,
381
+ alertMsg: `'${input_}'의 시작일이 종료일 보다 늦습니다.`,
382
+ el: sdate,
383
+ phase: _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].MATCH
384
+ };
385
+ break;
323
386
  }
324
387
  }
325
- else if (!this.result.flag) {
326
- break;
327
- }
328
388
  }
329
389
  }
330
390
  /** validation을 실행한다. */
331
- run(form) {
332
- this.init();
391
+ run(form,
392
+ /** validation 추가 설정*/ config) {
393
+ this.#init();
333
394
  for (const el of form.elements) {
334
- if (this.result.flag) {
335
- if (['INPUT', 'SELECT', 'TEXTAREA'].includes(el.tagName)) {
336
- if (!el.disabled) {
337
- this.#required(el);
338
- this.#setEl(el);
339
- }
395
+ if (['INPUT', 'SELECT', 'TEXTAREA'].includes(el.tagName)) {
396
+ if (!el.disabled) {
397
+ this.#setEl(el);
340
398
  }
341
399
  }
342
- else {
343
- break;
344
- }
345
400
  }
346
401
  if (this.result.flag) {
347
- this.#requiredRadio();
402
+ this.#requiredEl();
348
403
  }
349
404
  if (this.result.flag) {
350
- this.#match();
405
+ this.#length();
351
406
  }
352
407
  if (this.result.flag) {
353
- this.#length();
408
+ this.#match(config?.regex);
354
409
  }
355
410
  if (this.result.flag) {
356
411
  this.result.phase = _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].DONE;