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