@nuka9510/simple-validation 1.2.7 → 1.2.8
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 +27 -75
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -33,50 +33,62 @@
|
|
|
33
33
|
[top-language]: https://img.shields.io/github/languages/top/nuka9510/simple-validation
|
|
34
34
|
|
|
35
35
|
## Install
|
|
36
|
-
|
|
36
|
+
|
|
37
|
+
```shell
|
|
37
38
|
npm i @nuka9510/simple-validation
|
|
38
39
|
```
|
|
39
|
-
|
|
40
|
+
|
|
41
|
+
```html
|
|
40
42
|
<script src="https://cdn.jsdelivr.net/npm/@nuka9510/simple-validation/dist/js/index.min.js"> </script>
|
|
41
43
|
```
|
|
42
|
-
|
|
44
|
+
|
|
45
|
+
```html
|
|
43
46
|
<script src="https://cdn.jsdelivr.net/npm/@nuka9510/simple-validation@latest/dist/js/index.min.js"> </script>
|
|
44
47
|
```
|
|
45
|
-
|
|
48
|
+
|
|
49
|
+
```html
|
|
46
50
|
<script src="https://cdn.jsdelivr.net/npm/@nuka9510/simple-validation@<specific-version>/dist/js/index.min.js"> </script>
|
|
47
51
|
```
|
|
48
|
-
|
|
52
|
+
|
|
53
|
+
```html
|
|
49
54
|
<script type="importmap">
|
|
50
55
|
{
|
|
51
56
|
"imports": { "@nuka9510/simple-validation": "https://cdn.jsdelivr.net/npm/@nuka9510/simple-validation/dist/esm/index.min.mjs" }
|
|
52
57
|
}
|
|
53
58
|
</script>
|
|
54
59
|
```
|
|
55
|
-
|
|
60
|
+
|
|
61
|
+
```html
|
|
56
62
|
<script type="importmap">
|
|
57
63
|
{
|
|
58
64
|
"imports": { "@nuka9510/simple-validation": "https://cdn.jsdelivr.net/npm/@nuka9510/simple-validation@latest/dist/esm/index.min.mjs" }
|
|
59
65
|
}
|
|
60
66
|
</script>
|
|
61
67
|
```
|
|
62
|
-
|
|
68
|
+
|
|
69
|
+
```html
|
|
63
70
|
<script type="importmap">
|
|
64
71
|
{
|
|
65
72
|
"imports": { "@nuka9510/simple-validation": "https://cdn.jsdelivr.net/npm/@nuka9510/simple-validation@<specific-version>/dist/esm/index.min.mjs" }
|
|
66
73
|
}
|
|
67
74
|
</script>
|
|
68
75
|
```
|
|
76
|
+
|
|
69
77
|
## Usage
|
|
70
|
-
|
|
71
|
-
|
|
78
|
+
|
|
79
|
+
- js
|
|
80
|
+
|
|
81
|
+
```js
|
|
72
82
|
const validation = new simpleValidation.Validation({ regex: { test: /^test/ } });
|
|
73
83
|
|
|
74
84
|
validation.run(form);
|
|
75
85
|
|
|
76
86
|
console.debug(validation.result);
|
|
77
87
|
```
|
|
78
|
-
|
|
79
|
-
|
|
88
|
+
|
|
89
|
+
- mjs
|
|
90
|
+
|
|
91
|
+
```js
|
|
80
92
|
import { Validation } from "@nuka9510/simple-validation";
|
|
81
93
|
|
|
82
94
|
const validation = new Validation({ regex: { test: /^test/ } });
|
|
@@ -85,74 +97,14 @@ validation.run(form);
|
|
|
85
97
|
|
|
86
98
|
console.debug(validation.result);
|
|
87
99
|
```
|
|
88
|
-
|
|
89
|
-
|
|
100
|
+
|
|
101
|
+
- cjs
|
|
102
|
+
|
|
103
|
+
```js
|
|
90
104
|
const simpleValidation = require('@nuka9510/simple-validation'),
|
|
91
105
|
validation = new simpleValidation.Validation({ regex: { test: /^test/ } });
|
|
92
106
|
|
|
93
107
|
validation.run(form);
|
|
94
108
|
|
|
95
109
|
console.debug(validation.result);
|
|
96
|
-
```
|
|
97
|
-
### example
|
|
98
|
-
```
|
|
99
|
-
example
|
|
100
|
-
├── js
|
|
101
|
-
│ └── index.mjs
|
|
102
|
-
└── view
|
|
103
|
-
└── index.html
|
|
104
|
-
```
|
|
105
|
-
* example/js/index.mjs
|
|
106
|
-
```
|
|
107
|
-
import { Validation } from "@nuka9510/simple-validation";
|
|
108
|
-
|
|
109
|
-
class Index {
|
|
110
|
-
constructor() {
|
|
111
|
-
this.onValidationCheckClick = this.onValidationCheckClick.bind(this);
|
|
112
|
-
|
|
113
|
-
this.init();
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
init() {
|
|
117
|
-
document.querySelectorAll('[data-action="validation-check-click"]').forEach((...arg) => { arg[0].addEventListener('click', this.onValidationCheckClick); });
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
onValidationCheckClick(ev) {
|
|
121
|
-
const validation = new Validation({ regex: { test: /^test/ } }),
|
|
122
|
-
result = document.querySelector('[data-name="result"]');
|
|
123
|
-
|
|
124
|
-
validation.run(form);
|
|
125
|
-
|
|
126
|
-
console.log(validation.result);
|
|
127
|
-
|
|
128
|
-
result.innerHTML = JSON.stringify(validation.result);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
new Index();
|
|
134
|
-
```
|
|
135
|
-
* example/view/index.html
|
|
136
|
-
```
|
|
137
|
-
<!DOCTYPE html>
|
|
138
|
-
<html lang="en">
|
|
139
|
-
<head>
|
|
140
|
-
<meta charset="UTF-8">
|
|
141
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
142
|
-
<title>Document</title>
|
|
143
|
-
</head>
|
|
144
|
-
<body>
|
|
145
|
-
<form name="form">
|
|
146
|
-
<input type="text" name="test" data-sv-pattern="test" required="test">
|
|
147
|
-
<button type="button" data-action="validation-check-click">validation-check</button>
|
|
148
|
-
</form>
|
|
149
|
-
<div data-name="result"></div>
|
|
150
|
-
</body>
|
|
151
|
-
<script type="importmap">
|
|
152
|
-
{
|
|
153
|
-
"imports": { "@nuka9510/simple-validation": "https://cdn.jsdelivr.net/npm/@nuka9510/simple-validation/dist/esm/index.min.mjs" }
|
|
154
|
-
}
|
|
155
|
-
</script>
|
|
156
|
-
<script type="module" src="../js/index.mjs"></script>
|
|
157
|
-
</html>
|
|
158
110
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuka9510/simple-validation",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.8",
|
|
4
4
|
"description": "simple validation util for web front-end",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"bugs": {
|
|
43
43
|
"url": "https://github.com/nuka9510/simple-validation/issues"
|
|
44
44
|
},
|
|
45
|
-
"homepage": "https://github.com/nuka9510/simple-validation",
|
|
45
|
+
"homepage": "https://github.com/nuka9510/simple-validation/wiki",
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/node": "^22.14.0",
|
|
48
48
|
"@types/webpack": "^5.28.5",
|