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