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