@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/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" required="옵션">
|
|
80
|
+
* <input type="checkbox" data-sv-name="checkbox1" required="옵션">
|
|
81
|
+
* <input type="checkbox" name="checkbox2" required="옵션">
|
|
82
|
+
* <input type="checkbox" name="checkbox2" 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,272 @@ 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;
|
|
185
176
|
break;
|
|
177
|
+
default:
|
|
178
|
+
this.#input.push(el);
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
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] = [];
|
|
186
191
|
}
|
|
192
|
+
this.#checkbox[name].push(el);
|
|
187
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')));
|
|
253
|
+
if (!_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(checkboxList) &&
|
|
254
|
+
checkboxList.some((...arg) => !arg[0].checked)) {
|
|
255
|
+
const checkbox = checkboxList.find((...arg) => !arg[0].checked), required = checkbox.getAttribute('required');
|
|
256
|
+
this.result = {
|
|
257
|
+
flag: false,
|
|
258
|
+
alertMsg: `'${required}'을/를 선택해주세요.`,
|
|
259
|
+
el: checkbox,
|
|
260
|
+
phase: _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].REQUIRED
|
|
261
|
+
};
|
|
223
262
|
break;
|
|
224
263
|
}
|
|
225
264
|
}
|
|
226
265
|
}
|
|
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 {
|
|
266
|
+
#requiredRadio() {
|
|
267
|
+
for (const name in this.#radio) {
|
|
268
|
+
const radioList = this.#radio[name].filter((...arg) => !_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(arg[0].getAttribute('required')));
|
|
269
|
+
if (!_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(radioList) &&
|
|
270
|
+
radioList.every((...arg) => !arg[0].checked)) {
|
|
271
|
+
const radio = radioList.find((...arg) => !arg[0].checked), required = radio.getAttribute('required');
|
|
272
|
+
this.result = {
|
|
273
|
+
flag: false,
|
|
274
|
+
alertMsg: `'${required}'을/를 선택해주세요.`,
|
|
275
|
+
el: radio,
|
|
276
|
+
phase: _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].REQUIRED
|
|
277
|
+
};
|
|
246
278
|
break;
|
|
247
279
|
}
|
|
248
280
|
}
|
|
249
281
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
if (
|
|
257
|
-
|
|
258
|
-
this.result
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
282
|
+
#length() {
|
|
283
|
+
for (const input of this.#input) {
|
|
284
|
+
const input_ = input.getAttribute('data-sv-input') || input.getAttribute('required'), length = input.value.length;
|
|
285
|
+
if (!(input instanceof HTMLSelectElement)) {
|
|
286
|
+
if (input.minLength >= 0 &&
|
|
287
|
+
input.maxLength >= 0) {
|
|
288
|
+
if (length < input.minLength ||
|
|
289
|
+
length > input.maxLength) {
|
|
290
|
+
this.result = {
|
|
291
|
+
flag: false,
|
|
292
|
+
alertMsg: `'${input_}'은/는 ${input.minLength}~${input.maxLength}자 이내로 입력해주세요.`,
|
|
293
|
+
el: input,
|
|
294
|
+
phase: _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].LENGTH
|
|
295
|
+
};
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
else if (input.minLength >= 0 &&
|
|
300
|
+
input.maxLength < 0) {
|
|
301
|
+
if (length < input.minLength) {
|
|
302
|
+
this.result = {
|
|
303
|
+
flag: false,
|
|
304
|
+
alertMsg: `'${input_}'은/는 ${input.minLength}자 이상으로 입력해주세요.`,
|
|
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.maxLength) {
|
|
314
|
+
this.result = {
|
|
315
|
+
flag: false,
|
|
316
|
+
alertMsg: `'${input_}'은/는 ${input.maxLength}자 이하로 입력해주세요.`,
|
|
317
|
+
el: input,
|
|
318
|
+
phase: _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].LENGTH
|
|
319
|
+
};
|
|
262
320
|
break;
|
|
263
321
|
}
|
|
264
322
|
}
|
|
265
323
|
}
|
|
266
324
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
325
|
+
}
|
|
326
|
+
#match(regex) {
|
|
327
|
+
if (this.result.flag) {
|
|
328
|
+
this.#isPattern(regex);
|
|
329
|
+
}
|
|
330
|
+
if (this.result.flag) {
|
|
331
|
+
this.#isDate();
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
#isPattern(regex = null) {
|
|
335
|
+
const regex_ = {
|
|
336
|
+
...this.#regex,
|
|
337
|
+
...(regex ?? {})
|
|
338
|
+
};
|
|
339
|
+
for (const input of this.#input) {
|
|
340
|
+
const pattern = input.getAttribute('data-sv-pattern');
|
|
341
|
+
if (Object.keys(regex_).includes(pattern)) {
|
|
342
|
+
const input_ = input.getAttribute('data-sv-input') || input.getAttribute('required'), value = input.value;
|
|
343
|
+
if (!_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(value) &&
|
|
344
|
+
!regex_[pattern].test(value)) {
|
|
345
|
+
this.result = {
|
|
346
|
+
flag: false,
|
|
347
|
+
alertMsg: `'${input_}'의 형식이 올바르지 않습니다.`,
|
|
348
|
+
el: input,
|
|
349
|
+
phase: _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].MATCH
|
|
350
|
+
};
|
|
351
|
+
break;
|
|
276
352
|
}
|
|
277
353
|
}
|
|
278
354
|
}
|
|
279
355
|
}
|
|
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
|
-
}
|
|
356
|
+
#isDate() {
|
|
357
|
+
for (const name in this.#date) {
|
|
358
|
+
const date = this.#date[name], sdate = date.S, edate = date.E;
|
|
359
|
+
if (!_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(sdate) &&
|
|
360
|
+
!_nuka9510_js_util__WEBPACK_IMPORTED_MODULE_0__.Util.empty(edate)) {
|
|
361
|
+
const input_ = sdate.getAttribute('data-sv-date') ||
|
|
362
|
+
edate.getAttribute('data-sv-date') ||
|
|
363
|
+
sdate.getAttribute('required') ||
|
|
364
|
+
edate.getAttribute('required');
|
|
365
|
+
if (sdate.valueAsNumber > edate.valueAsNumber) {
|
|
366
|
+
this.result = {
|
|
367
|
+
flag: false,
|
|
368
|
+
alertMsg: `'${input_}'의 시작일이 종료일 보다 늦습니다.`,
|
|
369
|
+
el: sdate,
|
|
370
|
+
phase: _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].MATCH
|
|
371
|
+
};
|
|
372
|
+
break;
|
|
320
373
|
}
|
|
321
374
|
}
|
|
322
|
-
else if (!this.result.flag) {
|
|
323
|
-
break;
|
|
324
|
-
}
|
|
325
375
|
}
|
|
326
376
|
}
|
|
327
377
|
/** validation을 실행한다. */
|
|
328
|
-
run(form
|
|
329
|
-
|
|
378
|
+
run(form,
|
|
379
|
+
/** validation 추가 설정*/ config) {
|
|
380
|
+
this.#init();
|
|
330
381
|
for (const el of form.elements) {
|
|
331
|
-
if (
|
|
332
|
-
if (
|
|
333
|
-
|
|
334
|
-
this.#required(el);
|
|
335
|
-
this.#setEl(el);
|
|
336
|
-
}
|
|
382
|
+
if (['INPUT', 'SELECT', 'TEXTAREA'].includes(el.tagName)) {
|
|
383
|
+
if (!el.disabled) {
|
|
384
|
+
this.#setEl(el);
|
|
337
385
|
}
|
|
338
386
|
}
|
|
339
|
-
else {
|
|
340
|
-
break;
|
|
341
|
-
}
|
|
342
387
|
}
|
|
343
388
|
if (this.result.flag) {
|
|
344
|
-
this.#
|
|
389
|
+
this.#requiredEl();
|
|
345
390
|
}
|
|
346
391
|
if (this.result.flag) {
|
|
347
|
-
this.#
|
|
392
|
+
this.#length();
|
|
348
393
|
}
|
|
349
394
|
if (this.result.flag) {
|
|
350
|
-
this.#
|
|
395
|
+
this.#match(config?.regex);
|
|
351
396
|
}
|
|
352
397
|
if (this.result.flag) {
|
|
353
398
|
this.result.phase = _enums_phase_js__WEBPACK_IMPORTED_MODULE_1__["default"].DONE;
|