@nuka9510/simple-validation 1.1.0 → 1.1.2
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/README.md +33 -39
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +23 -92
- package/dist/index.min.js +1 -1
- package/dist/index.mjs +2 -1
- package/package.json +5 -5
- package/src/index.mts +5 -1
- package/src/index.ts +7 -0
- package/tsconfig.json +4 -1
package/README.md
CHANGED
|
@@ -32,68 +32,62 @@
|
|
|
32
32
|
|
|
33
33
|
[top-language]: https://img.shields.io/github/languages/top/nuka9510/simple-validation
|
|
34
34
|
|
|
35
|
-
# simple-validation
|
|
36
|
-
## Installation
|
|
37
|
-
```
|
|
38
|
-
npm i @nuka9510/simple-validation
|
|
39
|
-
```
|
|
40
35
|
## Usage
|
|
41
|
-
### js (> 1.1.
|
|
42
|
-
#### cdn
|
|
36
|
+
### js (> 1.1.2)
|
|
43
37
|
```
|
|
44
38
|
<script src="https://cdn.jsdelivr.net/npm/@nuka9510/simple-validation/dist/index.min.js"> </script>
|
|
39
|
+
OR
|
|
40
|
+
<script src="https://cdn.jsdelivr.net/npm/@nuka9510/simple-validation@latest/dist/index.min.js"> </script>
|
|
41
|
+
OR
|
|
42
|
+
<script src="https://cdn.jsdelivr.net/npm/@nuka9510/simple-validation@<specific-version>/dist/index.min.js"> </script>
|
|
45
43
|
```
|
|
46
|
-
or
|
|
47
44
|
```
|
|
48
|
-
<
|
|
45
|
+
<form name="form">
|
|
46
|
+
<input type="text" name="test" data-sv-pattern="test" required="test">
|
|
47
|
+
</form>
|
|
48
|
+
<script type="text/javascript">
|
|
49
|
+
const validation = new simpleValidation.Validation({ regex: { test: /^test/ } });
|
|
50
|
+
|
|
51
|
+
validation.run(form);
|
|
52
|
+
|
|
53
|
+
console.debug(validation.result);
|
|
54
|
+
</script>
|
|
49
55
|
```
|
|
50
|
-
|
|
56
|
+
### mjs
|
|
51
57
|
```
|
|
52
|
-
|
|
58
|
+
npm i @nuka9510/simple-validation
|
|
53
59
|
```
|
|
54
|
-
### module
|
|
55
|
-
#### npm
|
|
56
60
|
```
|
|
57
61
|
<script type="importmap">
|
|
58
62
|
{
|
|
59
63
|
"imports": {
|
|
60
64
|
"@nuka9510/js-util": "<path>/node_modules/@nuka9510/js-util/dist/index.mjs",
|
|
61
65
|
"@nuka9510/simple-validation": "<path>/node_modules/@nuka9510/simple-validation/dist/index.mjs"
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
</script>
|
|
65
|
-
```
|
|
66
|
-
#### cdn
|
|
67
|
-
```
|
|
68
|
-
<script type="importmap">
|
|
69
|
-
{
|
|
70
|
-
"imports": {
|
|
66
|
+
OR
|
|
71
67
|
"@nuka9510/js-util": "https://cdn.jsdelivr.net/npm/@nuka9510/js-util/dist/index.mjs",
|
|
72
68
|
"@nuka9510/simple-validation": "https://cdn.jsdelivr.net/npm/@nuka9510/simple-validation/dist/index.mjs"
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
</script>
|
|
76
|
-
```
|
|
77
|
-
or
|
|
78
|
-
```
|
|
79
|
-
<script type="importmap">
|
|
80
|
-
{
|
|
81
|
-
"imports": {
|
|
69
|
+
OR
|
|
82
70
|
"@nuka9510/js-util": "https://cdn.jsdelivr.net/npm/@nuka9510/js-util@latest/dist/index.mjs",
|
|
83
71
|
"@nuka9510/simple-validation": "https://cdn.jsdelivr.net/npm/@nuka9510/simple-validation@latest/dist/index.mjs"
|
|
72
|
+
OR
|
|
73
|
+
"@nuka9510/js-util": "https://cdn.jsdelivr.net/npm/@nuka9510/js-util@<specific-version>/dist/index.mjs",
|
|
74
|
+
"@nuka9510/simple-validation": "https://cdn.jsdelivr.net/npm/@nuka9510/simple-validation@<specific-version>/dist/index.mjs"
|
|
84
75
|
}
|
|
85
76
|
}
|
|
86
77
|
</script>
|
|
87
78
|
```
|
|
88
|
-
or
|
|
89
79
|
```
|
|
90
|
-
<
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
80
|
+
<form name="form">
|
|
81
|
+
<input type="text" name="test" data-sv-pattern="test" required="test">
|
|
82
|
+
</form>
|
|
83
|
+
<script type="text/javascript">
|
|
84
|
+
import { SValidation } from "@nuka9510/simple-validation";
|
|
85
|
+
|
|
86
|
+
const validation = new SValidation({ regex: { test: /^test/ } });
|
|
87
|
+
|
|
88
|
+
validation.run(form);
|
|
89
|
+
|
|
90
|
+
console.debug(validation.result);
|
|
97
91
|
</script>
|
|
98
92
|
```
|
|
99
93
|
### example
|
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
ADDED
package/dist/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
var simpleValidation;
|
|
1
2
|
/******/ (() => { // webpackBootstrap
|
|
3
|
+
/******/ "use strict";
|
|
2
4
|
/******/ var __webpack_modules__ = ([
|
|
3
5
|
/* 0 */,
|
|
4
6
|
/* 1 */
|
|
5
7
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
6
8
|
|
|
7
|
-
"use strict";
|
|
8
9
|
__webpack_require__.r(__webpack_exports__);
|
|
9
10
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
10
11
|
/* harmony export */ "default": () => (/* binding */ Validation)
|
|
@@ -304,17 +305,23 @@ class Validation {
|
|
|
304
305
|
|
|
305
306
|
/***/ }),
|
|
306
307
|
/* 2 */
|
|
307
|
-
/***/ ((
|
|
308
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
308
309
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
/*
|
|
313
|
-
/*
|
|
314
|
-
/***/ ((__unused_webpack___webpack_module__, __nested_webpack_exports__, __nested_webpack_require_184__) => {
|
|
310
|
+
__webpack_require__.r(__webpack_exports__);
|
|
311
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
312
|
+
/* harmony export */ JUtil: () => (/* reexport safe */ _util_mjs__WEBPACK_IMPORTED_MODULE_0__["default"])
|
|
313
|
+
/* harmony export */ });
|
|
314
|
+
/* harmony import */ var _util_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3);
|
|
315
315
|
|
|
316
|
-
|
|
317
|
-
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
/***/ }),
|
|
320
|
+
/* 3 */
|
|
321
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
322
|
+
|
|
323
|
+
__webpack_require__.r(__webpack_exports__);
|
|
324
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
318
325
|
/* harmony export */ "default": () => (/* binding */ Util)
|
|
319
326
|
/* harmony export */ });
|
|
320
327
|
class Util {
|
|
@@ -730,82 +737,6 @@ class Util {
|
|
|
730
737
|
}
|
|
731
738
|
|
|
732
739
|
|
|
733
|
-
/***/ })
|
|
734
|
-
/******/ ]);
|
|
735
|
-
/************************************************************************/
|
|
736
|
-
/******/ // The module cache
|
|
737
|
-
/******/ var __webpack_module_cache__ = {};
|
|
738
|
-
/******/
|
|
739
|
-
/******/ // The require function
|
|
740
|
-
/******/ function __nested_webpack_require_14055__(moduleId) {
|
|
741
|
-
/******/ // Check if module is in cache
|
|
742
|
-
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
743
|
-
/******/ if (cachedModule !== undefined) {
|
|
744
|
-
/******/ return cachedModule.exports;
|
|
745
|
-
/******/ }
|
|
746
|
-
/******/ // Create a new module (and put it into the cache)
|
|
747
|
-
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
748
|
-
/******/ // no module.id needed
|
|
749
|
-
/******/ // no module.loaded needed
|
|
750
|
-
/******/ exports: {}
|
|
751
|
-
/******/ };
|
|
752
|
-
/******/
|
|
753
|
-
/******/ // Execute the module function
|
|
754
|
-
/******/ __webpack_modules__[moduleId](module, module.exports, __nested_webpack_require_14055__);
|
|
755
|
-
/******/
|
|
756
|
-
/******/ // Return the exports of the module
|
|
757
|
-
/******/ return module.exports;
|
|
758
|
-
/******/ }
|
|
759
|
-
/******/
|
|
760
|
-
/************************************************************************/
|
|
761
|
-
/******/ /* webpack/runtime/define property getters */
|
|
762
|
-
/******/ (() => {
|
|
763
|
-
/******/ // define getter functions for harmony exports
|
|
764
|
-
/******/ __nested_webpack_require_14055__.d = (exports, definition) => {
|
|
765
|
-
/******/ for(var key in definition) {
|
|
766
|
-
/******/ if(__nested_webpack_require_14055__.o(definition, key) && !__nested_webpack_require_14055__.o(exports, key)) {
|
|
767
|
-
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
768
|
-
/******/ }
|
|
769
|
-
/******/ }
|
|
770
|
-
/******/ };
|
|
771
|
-
/******/ })();
|
|
772
|
-
/******/
|
|
773
|
-
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
774
|
-
/******/ (() => {
|
|
775
|
-
/******/ __nested_webpack_require_14055__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
776
|
-
/******/ })();
|
|
777
|
-
/******/
|
|
778
|
-
/******/ /* webpack/runtime/make namespace object */
|
|
779
|
-
/******/ (() => {
|
|
780
|
-
/******/ // define __esModule on exports
|
|
781
|
-
/******/ __nested_webpack_require_14055__.r = (exports) => {
|
|
782
|
-
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
783
|
-
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
784
|
-
/******/ }
|
|
785
|
-
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
786
|
-
/******/ };
|
|
787
|
-
/******/ })();
|
|
788
|
-
/******/
|
|
789
|
-
/************************************************************************/
|
|
790
|
-
var __nested_webpack_exports__ = {};
|
|
791
|
-
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
|
|
792
|
-
(() => {
|
|
793
|
-
__nested_webpack_require_14055__.r(__nested_webpack_exports__);
|
|
794
|
-
/* harmony export */ __nested_webpack_require_14055__.d(__nested_webpack_exports__, {
|
|
795
|
-
/* harmony export */ JUtil: () => (/* reexport safe */ _util_mjs__WEBPACK_IMPORTED_MODULE_0__["default"])
|
|
796
|
-
/* harmony export */ });
|
|
797
|
-
/* harmony import */ var _util_mjs__WEBPACK_IMPORTED_MODULE_0__ = __nested_webpack_require_14055__(1);
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
})();
|
|
802
|
-
|
|
803
|
-
var __webpack_export_target__ = exports;
|
|
804
|
-
for(var __webpack_i__ in __nested_webpack_exports__) __webpack_export_target__[__webpack_i__] = __nested_webpack_exports__[__webpack_i__];
|
|
805
|
-
if(__nested_webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, "__esModule", { value: true });
|
|
806
|
-
/******/ })()
|
|
807
|
-
;
|
|
808
|
-
|
|
809
740
|
/***/ })
|
|
810
741
|
/******/ ]);
|
|
811
742
|
/************************************************************************/
|
|
@@ -864,21 +795,21 @@ if(__nested_webpack_exports__.__esModule) Object.defineProperty(__webpack_export
|
|
|
864
795
|
/******/
|
|
865
796
|
/************************************************************************/
|
|
866
797
|
var __webpack_exports__ = {};
|
|
867
|
-
// This entry needs to be wrapped in an IIFE because it needs to be in
|
|
798
|
+
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
|
|
868
799
|
(() => {
|
|
869
|
-
"use strict";
|
|
870
800
|
__webpack_require__.r(__webpack_exports__);
|
|
871
801
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
872
|
-
/* harmony export */
|
|
802
|
+
/* harmony export */ JUtil: () => (/* reexport safe */ _nuka9510_js_util__WEBPACK_IMPORTED_MODULE_1__.JUtil),
|
|
803
|
+
/* harmony export */ Validation: () => (/* reexport safe */ _validation_mjs__WEBPACK_IMPORTED_MODULE_0__["default"])
|
|
873
804
|
/* harmony export */ });
|
|
874
805
|
/* harmony import */ var _validation_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
|
|
806
|
+
/* harmony import */ var _nuka9510_js_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
|
|
807
|
+
|
|
875
808
|
|
|
876
809
|
|
|
877
810
|
|
|
878
811
|
})();
|
|
879
812
|
|
|
880
|
-
|
|
881
|
-
for(var __webpack_i__ in __webpack_exports__) __webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
882
|
-
if(__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, "__esModule", { value: true });
|
|
813
|
+
simpleValidation = __webpack_exports__;
|
|
883
814
|
/******/ })()
|
|
884
815
|
;
|
package/dist/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var e={
|
|
1
|
+
var simpleValidation;(()=>{"use strict";var e={d:(t,r)=>{for(var s in r)e.o(r,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:r[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{JUtil:()=>r,Validation:()=>s});class r{static empty(e){let t=[void 0,null,0,""].includes(e);return t||(e.constructor==Object?t=0==Object.keys(e).length&&0==Object.keys(Object.getPrototypeOf(e)).length:(e.constructor==NodeList||Array.isArray(e))&&(t=0==e.length)),t}static isNumber(e,t=!1){let r=!Number.isNaN(Number(e))&&["number","string"].includes(typeof e)&&!/^\s*$/.test(`${e}`);return r&&t&&(r="number"==typeof e),r}static isObject(e){return e?.constructor==Object}static numberFormat(e,t=0,s=".",i=","){const a=String(e).split(".");return a[0]=a[0].replace(/\B(?=(\d{3})+(?!\d))/g,i),r.empty(a[1])||(a[1]=a[1].substring(0,t)),r.empty(a[1])?a[0]:a[0].concat(s,a[1])}static strftime(e,t){const r=["January","February","March","April","May","June","July","August","September","October","November","December"],s=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];return(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=t.replace(/(%{1})/g,"\\$1")).replace(/(\\%){2}/g,"%")).replace(/\\%Y/g,String(e.getFullYear()))).replace(/\\%y/g,String(e.getFullYear()).replace(/^\d+(\d{2})$/,"$1"))).replace(/\\%B/g,r[e.getMonth()])).replace(/\\%b/g,r[e.getMonth()].replace(/^(\w{3})\w*$/,"$1"))).replace(/\\%m/g,String(e.getMonth()+1).replace(/^(\d{1})$/,"0$1"))).replace(/\\%d/g,String(e.getDate()).replace(/^(\d{1})$/,"0$1"))).replace(/\\%A/g,s[e.getDay()])).replace(/\\%a/g,s[e.getDay()].replace(/^(\w{3})\w*$/,"$1"))).replace(/\\%H/g,String(e.getHours()).replace(/^(\d{1})$/,"0$1"))).replace(/\\%I/g,String(e.getHours()>12?e.getHours()-12:e.getHours()).replace(/^0$/,"12").replace(/^(\d{1})$/,"0$1"))).replace(/\\%p/g,e.getHours()<12?"AM":"PM")).replace(/\\%M/g,String(e.getMinutes()).replace(/^(\d{1})$/,"0$1"))).replace(/\\%S/g,String(e.getSeconds()).replace(/^(\d{1})$/,"0$1"))}static checkdate(e,t,r){const s=new Date(e,t-1,r);return s.getFullYear()==e&&s.getMonth()+1==t&&s.getDate()==r}static equaldate(e,t=new Date){return r.strftime(e,"%Y-%m-%d")==r.strftime(t,"%Y-%m-%d")}static getWeek(e,t=!0){const r=["일요일","월요일","화요일","수요일","목요일","금요일","토요일"][e.getDay()];return t?r:r.replace(/^([ㄱ-ㅎㅏ-ㅣ가-힣]{1})[ㄱ-ㅎㅏ-ㅣ가-힣]+$/,"$1")}static addDate(e,t){return new Date(e.getFullYear()+(r.isNumber(t.year,!0)?t.year:0),e.getMonth()+(r.isNumber(t.month,!0)?t.month:0),e.getDate()+(r.isNumber(t.day,!0)?t.day:0),e.getHours()+(r.isNumber(t.hour,!0)?t.hour:0),e.getMinutes()+(r.isNumber(t.minute,!0)?t.minute:0),e.getSeconds()+(r.isNumber(t.second,!0)?t.second:0),e.getMilliseconds()+(r.isNumber(t.millisecond,!0)?t.millisecond:0))}static subDate(e,t){return new Date(e.getFullYear()-(r.isNumber(t.year,!0)?t.year:0),e.getMonth()-(r.isNumber(t.month,!0)?t.month:0),e.getDate()-(r.isNumber(t.day,!0)?t.day:0),e.getHours()-(r.isNumber(t.hour,!0)?t.hour:0),e.getMinutes()-(r.isNumber(t.minute,!0)?t.minute:0),e.getSeconds()-(r.isNumber(t.second,!0)?t.second:0),e.getMilliseconds()-(r.isNumber(t.millisecond,!0)?t.millisecond:0))}static xor(e,t){return!(e&&t)&&(e||t)}static formDataToJson(e){return JSON.stringify(Object.fromEntries([...new Set(e.keys())].map(((...t)=>[t[0],e.getAll(t[0]).length>1?e.getAll(t[0]):e.get(t[0])]))))}static percentage(e,t){return e*(t/100)}static ratio(e,t,r=!0){const s=r?[1,0]:[0,1];return t*e[s[0]]/e[s[1]]}static arithmeticSequence(e,t,r,s){return e+(s-t)*r}static geometricSequence(e,t,r,s){return e/r**(t-1)*r**(s-1)}static decimalAdjust(e,t,r=0){const[s,i="0"]=t.toString().split("e"),a=Math[e](Number(`${s}e${parseInt(i)+r}`)),[n,l="0"]=a.toString().split("e");return Number(`${n}e${parseInt(l)-r}`)}static encodeHtmlEntity(e){const t=document.createElement("textarea");return t.innerText=e,t.innerHTML}static decodeHtmlEntity(e){const t=document.createElement("textarea");return t.innerHTML=e,t.innerText}static copy(e){if(r.isObject(e)){const t={};for(const s in e)t[s]=r.copy(e[s]);return t}if(Array.isArray(e)){const t=[];for(const s of e)t.push(r.copy(s));return t}return e}static numRange(e,t){let r=t-e;const s=r>0;return r=Math.abs(r)+1,[...new Array(r)].map(((...t)=>t[1]*(s?1:-1)+e))}static arrayChunk(e,t){if(!r.isNumber(t,!0))throw new TypeError("size는 숫자 타입 이어야 합니다.");if(t<=0&&Number.isInteger(t))throw new RangeError("size는 0보다 큰 정수여야 합니다.");const s=[];return r.numRange(0,r.decimalAdjust("ceil",e.length/t)+(e.length>0?-1:0)).forEach(((...r)=>{s.push(e.slice(r[0]*t,(r[0]+1)*t))})),s}}class s{result;#e;#t;#r;constructor(e){this.init(e)}init(e=null){this.#s(),this.#i(),this.#a(),this.#n(e?.regex)}#s(){this.result={flag:!0,alertMsg:null,el:null}}#i(){this.#e={}}#a(){this.#t={}}#n(e=null){this.#r=!r.empty(e)&&r.isObject(e)?{...this.#r,...e}:{...this.#r}}#l(e){const t=e.getAttribute("required");r.empty(t)||("radio"==e.type?this.#u(e):r.empty(e.value)&&(this.result.flag=!1,this.result.alertMsg=`'${t}'을/를 입력해 주세요.`,this.result.el=e))}#c(){for(const e in this.#t){const t=this.#t[e][0];if(!this.#t[e].some(((...e)=>e[0].checked))){this.result.flag=!1,this.result.alertMsg=`'${e}'을/를 선택해주세요.`,this.result.el=t;break}}}#o(e){const t=e.dataset.svPattern,s=e.dataset.svDate;if(r.empty(t)||(r.empty(this.#e.el)&&(this.#e.el=[]),this.#e.el?.push(e)),!r.empty(s)){const t=e.dataset.svDateState;switch(t){case"S":case"E":r.empty(this.#e.date)&&(this.#e.date={}),r.empty(this.#e.date[s])&&(this.#e.date[s]={}),this.#e.date[s][t]=e}}}#u(e){const t=e.getAttribute("required");r.empty(t)||(r.empty(this.#t[t])?this.#t[t]=[e]:this.#t[t].push(e))}#g(){for(const e in this.#e){if(!this.result.flag)break;switch(e){case"date":this.#h(this.#e[e]);break;case"el":this.#d(this.#e[e])}}}#h(e){for(const t in e){if(!this.result.flag)break;{const s=e[t].S.value,i=e[t].E.value;if(!r.empty(s)&&!r.empty(i)){const r=e[t].S.dataset.svInputName||e[t].E.dataset.svInputName,a=e[t].S.getAttribute("required")||e[t].E.getAttribute("required");new Date(s).getTime()>new Date(i).getTime()&&(this.result.flag=!1,this.result.alertMsg=`'${r||a}'의 시작일이 종료일 보다 늦습니다.`,this.result.el=e[t].S)}}}}#d(e){if(Array.isArray(e))for(const t of e){const e=t.dataset.svPattern,s=t.dataset.svInputName,i=t.getAttribute("required"),a=t.value;if(Object.keys(this.#r).includes(e)&&!r.empty(a)&&!this.#r[e].test(a)){this.result.flag=!1,this.result.alertMsg=`'${s||i}'의 형식이 올바르지 않습니다.`,this.result.el=t;break}}else{const t=e.dataset.svPattern,s=e.dataset.svInputName,i=e.getAttribute("required"),a=e.value;Object.keys(this.#r).includes(t)&&(r.empty(a)||this.#r[t].test(a)||(this.result.flag=!1,this.result.alertMsg=`'${s||i}'의 형식이 올바르지 않습니다.`,this.result.el=e))}}#m(){for(const e in this.#e)if("el"==e&&this.result.flag)for(const t of this.#e[e]){const e=t.dataset.svInputName,r=t.getAttribute("required"),s=t.value.length;if(!(t instanceof HTMLSelectElement))if(t.minLength>=0&&t.maxLength>=0){if(s<t.minLength||s>t.maxLength){this.result.flag=!1,this.result.alertMsg=`'${e||r}'은/는 ${t.minLength}~${t.maxLength}자 이내로 입력해주세요.`,this.result.el=t;break}}else if(t.minLength>=0&&t.maxLength<0){if(s<t.minLength){this.result.flag=!1,this.result.alertMsg=`'${e||r}'은/는 ${t.minLength}자 이상으로 입력해주세요.`,this.result.el=t;break}}else if(t.minLength<0&&t.maxLength>=0&&s>t.maxLength){this.result.flag=!1,this.result.alertMsg=`'${e||r}'은/는 ${t.maxLength}자 이하로 입력해주세요.`,this.result.el=t;break}}else if(!this.result.flag)break}run(e){this.init();for(const t of e.elements){if(!this.result.flag)break;["INPUT","SELECT","TEXTAREA"].includes(t.tagName)&&(t.disabled||(this.#l(t),this.#o(t)))}this.result.flag&&this.#c(),this.result.flag&&this.#g(),this.result.flag&&this.#m()}}simpleValidation=t})();
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuka9510/simple-validation",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "simple validation util for web front-end",
|
|
5
|
-
"main": "dist/index.
|
|
5
|
+
"main": "dist/index.mjs",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
8
|
"build": "rm -r -f dist && tsc && webpack --config webpack.config.js",
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
"url": "https://github.com/nuka9510/simple-validation/issues"
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://github.com/nuka9510/simple-validation",
|
|
28
|
-
"dependencies": {
|
|
29
|
-
"@nuka9510/js-util": "^1.1.0"
|
|
30
|
-
},
|
|
31
28
|
"devDependencies": {
|
|
32
29
|
"@types/node": "^22.14.0",
|
|
33
30
|
"@types/webpack": "^5.28.5",
|
|
34
31
|
"ts-node": "^10.9.2",
|
|
35
32
|
"webpack": "^5.99.5",
|
|
36
33
|
"webpack-cli": "^6.0.1"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@nuka9510/js-util": "^1.1.2"
|
|
37
37
|
}
|
|
38
38
|
}
|
package/src/index.mts
CHANGED
package/src/index.ts
ADDED