@nuka9510/simple-validation 1.3.0 → 1.4.0
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 +237 -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 +237 -192
- package/dist/esm/index.mjs.map +1 -1
- package/dist/js/index.js +237 -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 +237 -192
- package/package.json +1 -1
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
|
-
|
|
66
|
-
#
|
|
67
|
-
|
|
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
|
|
77
|
-
* <input type="text" name="text"
|
|
78
|
-
*
|
|
79
|
-
* <input type="date" name="
|
|
80
|
-
* <input type="date" name="
|
|
81
|
-
* <input type="date" name="
|
|
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" required="옵션">
|
|
83
|
+
* <input type="checkbox" data-sv-name="checkbox1" required="옵션">
|
|
84
|
+
* <input type="checkbox" name="checkbox2" required="옵션">
|
|
85
|
+
* <input type="checkbox" name="checkbox2" 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/
|
|
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 {
|
|
100
|
+
* import { Validation } from "@nuka9510/simple-validation";
|
|
93
101
|
*
|
|
94
|
-
* const validation = new
|
|
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(
|
|
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.#
|
|
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,272 @@ class Validation {
|
|
|
122
130
|
phase: _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].INIT
|
|
123
131
|
};
|
|
124
132
|
}
|
|
125
|
-
|
|
126
|
-
#
|
|
127
|
-
|
|
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
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
-
|
|
168
|
-
#
|
|
169
|
-
const
|
|
170
|
-
if (!_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(
|
|
171
|
-
|
|
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.#
|
|
182
|
-
this.#
|
|
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.#
|
|
178
|
+
this.#date[name][state] = el;
|
|
188
179
|
break;
|
|
180
|
+
default:
|
|
181
|
+
this.#input.push(el);
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
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] = [];
|
|
189
194
|
}
|
|
195
|
+
this.#checkbox[name].push(el);
|
|
190
196
|
}
|
|
191
197
|
}
|
|
192
|
-
/** `#radio`에 type이 'radio'인 Element를 담는다. */
|
|
193
198
|
#setRadio(el) {
|
|
194
|
-
const
|
|
195
|
-
if (!_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(
|
|
196
|
-
if (_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(this.#radio[
|
|
197
|
-
this.#radio[
|
|
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
|
-
|
|
200
|
-
|
|
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
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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
|
-
|
|
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')));
|
|
256
|
+
if (!_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(checkboxList) &&
|
|
257
|
+
checkboxList.some((...arg) => !arg[0].checked)) {
|
|
258
|
+
const checkbox = checkboxList.find((...arg) => !arg[0].checked), required = checkbox.getAttribute('required');
|
|
259
|
+
this.result = {
|
|
260
|
+
flag: false,
|
|
261
|
+
alertMsg: `'${required}'을/를 선택해주세요.`,
|
|
262
|
+
el: checkbox,
|
|
263
|
+
phase: _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].REQUIRED
|
|
264
|
+
};
|
|
226
265
|
break;
|
|
227
266
|
}
|
|
228
267
|
}
|
|
229
268
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
if (
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
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 {
|
|
269
|
+
#requiredRadio() {
|
|
270
|
+
for (const name in this.#radio) {
|
|
271
|
+
const radioList = this.#radio[name].filter((...arg) => !_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(arg[0].getAttribute('required')));
|
|
272
|
+
if (!_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(radioList) &&
|
|
273
|
+
radioList.every((...arg) => !arg[0].checked)) {
|
|
274
|
+
const radio = radioList.find((...arg) => !arg[0].checked), required = radio.getAttribute('required');
|
|
275
|
+
this.result = {
|
|
276
|
+
flag: false,
|
|
277
|
+
alertMsg: `'${required}'을/를 선택해주세요.`,
|
|
278
|
+
el: radio,
|
|
279
|
+
phase: _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].REQUIRED
|
|
280
|
+
};
|
|
249
281
|
break;
|
|
250
282
|
}
|
|
251
283
|
}
|
|
252
284
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
if (
|
|
260
|
-
|
|
261
|
-
this.result
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
285
|
+
#length() {
|
|
286
|
+
for (const input of this.#input) {
|
|
287
|
+
const input_ = input.getAttribute('data-sv-input') || input.getAttribute('required'), length = input.value.length;
|
|
288
|
+
if (!(input instanceof HTMLSelectElement)) {
|
|
289
|
+
if (input.minLength >= 0 &&
|
|
290
|
+
input.maxLength >= 0) {
|
|
291
|
+
if (length < input.minLength ||
|
|
292
|
+
length > input.maxLength) {
|
|
293
|
+
this.result = {
|
|
294
|
+
flag: false,
|
|
295
|
+
alertMsg: `'${input_}'은/는 ${input.minLength}~${input.maxLength}자 이내로 입력해주세요.`,
|
|
296
|
+
el: input,
|
|
297
|
+
phase: _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].LENGTH
|
|
298
|
+
};
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
else if (input.minLength >= 0 &&
|
|
303
|
+
input.maxLength < 0) {
|
|
304
|
+
if (length < input.minLength) {
|
|
305
|
+
this.result = {
|
|
306
|
+
flag: false,
|
|
307
|
+
alertMsg: `'${input_}'은/는 ${input.minLength}자 이상으로 입력해주세요.`,
|
|
308
|
+
el: input,
|
|
309
|
+
phase: _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].LENGTH
|
|
310
|
+
};
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
else if (input.minLength < 0 &&
|
|
315
|
+
input.maxLength >= 0) {
|
|
316
|
+
if (length > input.maxLength) {
|
|
317
|
+
this.result = {
|
|
318
|
+
flag: false,
|
|
319
|
+
alertMsg: `'${input_}'은/는 ${input.maxLength}자 이하로 입력해주세요.`,
|
|
320
|
+
el: input,
|
|
321
|
+
phase: _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].LENGTH
|
|
322
|
+
};
|
|
265
323
|
break;
|
|
266
324
|
}
|
|
267
325
|
}
|
|
268
326
|
}
|
|
269
327
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
328
|
+
}
|
|
329
|
+
#match(regex) {
|
|
330
|
+
if (this.result.flag) {
|
|
331
|
+
this.#isPattern(regex);
|
|
332
|
+
}
|
|
333
|
+
if (this.result.flag) {
|
|
334
|
+
this.#isDate();
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
#isPattern(regex = null) {
|
|
338
|
+
const regex_ = {
|
|
339
|
+
...this.#regex,
|
|
340
|
+
...(regex ?? {})
|
|
341
|
+
};
|
|
342
|
+
for (const input of this.#input) {
|
|
343
|
+
const pattern = input.getAttribute('data-sv-pattern');
|
|
344
|
+
if (Object.keys(regex_).includes(pattern)) {
|
|
345
|
+
const input_ = input.getAttribute('data-sv-input') || input.getAttribute('required'), value = input.value;
|
|
346
|
+
if (!_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(value) &&
|
|
347
|
+
!regex_[pattern].test(value)) {
|
|
348
|
+
this.result = {
|
|
349
|
+
flag: false,
|
|
350
|
+
alertMsg: `'${input_}'의 형식이 올바르지 않습니다.`,
|
|
351
|
+
el: input,
|
|
352
|
+
phase: _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].MATCH
|
|
353
|
+
};
|
|
354
|
+
break;
|
|
279
355
|
}
|
|
280
356
|
}
|
|
281
357
|
}
|
|
282
358
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
if (
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
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
|
-
}
|
|
359
|
+
#isDate() {
|
|
360
|
+
for (const name in this.#date) {
|
|
361
|
+
const date = this.#date[name], sdate = date.S, edate = date.E;
|
|
362
|
+
if (!_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(sdate) &&
|
|
363
|
+
!_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(edate)) {
|
|
364
|
+
const input_ = sdate.getAttribute('data-sv-date') ||
|
|
365
|
+
edate.getAttribute('data-sv-date') ||
|
|
366
|
+
sdate.getAttribute('required') ||
|
|
367
|
+
edate.getAttribute('required');
|
|
368
|
+
if (sdate.valueAsNumber > edate.valueAsNumber) {
|
|
369
|
+
this.result = {
|
|
370
|
+
flag: false,
|
|
371
|
+
alertMsg: `'${input_}'의 시작일이 종료일 보다 늦습니다.`,
|
|
372
|
+
el: sdate,
|
|
373
|
+
phase: _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].MATCH
|
|
374
|
+
};
|
|
375
|
+
break;
|
|
323
376
|
}
|
|
324
377
|
}
|
|
325
|
-
else if (!this.result.flag) {
|
|
326
|
-
break;
|
|
327
|
-
}
|
|
328
378
|
}
|
|
329
379
|
}
|
|
330
380
|
/** validation을 실행한다. */
|
|
331
|
-
run(form
|
|
332
|
-
|
|
381
|
+
run(form,
|
|
382
|
+
/** validation 추가 설정*/ config) {
|
|
383
|
+
this.#init();
|
|
333
384
|
for (const el of form.elements) {
|
|
334
|
-
if (
|
|
335
|
-
if (
|
|
336
|
-
|
|
337
|
-
this.#required(el);
|
|
338
|
-
this.#setEl(el);
|
|
339
|
-
}
|
|
385
|
+
if (['INPUT', 'SELECT', 'TEXTAREA'].includes(el.tagName)) {
|
|
386
|
+
if (!el.disabled) {
|
|
387
|
+
this.#setEl(el);
|
|
340
388
|
}
|
|
341
389
|
}
|
|
342
|
-
else {
|
|
343
|
-
break;
|
|
344
|
-
}
|
|
345
390
|
}
|
|
346
391
|
if (this.result.flag) {
|
|
347
|
-
this.#
|
|
392
|
+
this.#requiredEl();
|
|
348
393
|
}
|
|
349
394
|
if (this.result.flag) {
|
|
350
|
-
this.#
|
|
395
|
+
this.#length();
|
|
351
396
|
}
|
|
352
397
|
if (this.result.flag) {
|
|
353
|
-
this.#
|
|
398
|
+
this.#match(config?.regex);
|
|
354
399
|
}
|
|
355
400
|
if (this.result.flag) {
|
|
356
401
|
this.result.phase = _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].DONE;
|