@zemkogabor/vue-form-validator 0.0.3 → 1.1.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/dist/vue-form-validator.js +48 -40
- package/package.json +20 -20
- package/dist/Validator.d.ts +0 -7
- package/dist/index.d.ts +0 -1
|
@@ -1,54 +1,62 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
|
|
3
|
-
function
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { inject as f, ref as u } from "vue";
|
|
2
|
+
const v = /* @__PURE__ */ Symbol("VALIDATOR_CONFIG");
|
|
3
|
+
function g(s) {
|
|
4
|
+
const a = f(
|
|
5
|
+
v,
|
|
6
|
+
void 0
|
|
7
|
+
);
|
|
8
|
+
if (!a || !a.messages)
|
|
9
|
+
throw new Error(
|
|
10
|
+
"[vue-form-validator] Validator messages are not provided. Did you forget to call app.provide(VALIDATOR_CONFIG_KEY, ...)?"
|
|
11
|
+
);
|
|
12
|
+
const r = a.messages, i = u(null);
|
|
13
|
+
function l(e) {
|
|
14
|
+
const t = s.value;
|
|
15
|
+
t !== null && (e !== null ? t.setCustomValidity(e) : t.setCustomValidity(""), i.value = o(t));
|
|
8
16
|
}
|
|
9
|
-
function o(
|
|
10
|
-
if (
|
|
11
|
-
return
|
|
12
|
-
if (
|
|
13
|
-
return e
|
|
14
|
-
if (
|
|
15
|
-
return e
|
|
16
|
-
if (
|
|
17
|
-
return e
|
|
18
|
-
if (
|
|
19
|
-
return e
|
|
20
|
-
if (
|
|
21
|
-
if (
|
|
22
|
-
return
|
|
23
|
-
if (
|
|
24
|
-
return
|
|
17
|
+
function o(e) {
|
|
18
|
+
if (e.validity.valueMissing)
|
|
19
|
+
return r.valueMissing;
|
|
20
|
+
if (e.validity.tooShort)
|
|
21
|
+
return r.tooShort(e.minLength);
|
|
22
|
+
if (e.validity.tooLong)
|
|
23
|
+
return r.tooLong(e.maxLength);
|
|
24
|
+
if (e.validity.rangeUnderflow)
|
|
25
|
+
return r.rangeUnderflow(e.min);
|
|
26
|
+
if (e.validity.rangeOverflow)
|
|
27
|
+
return r.rangeOverflow(e.max);
|
|
28
|
+
if (e.validity.typeMismatch) {
|
|
29
|
+
if (e.type === "email")
|
|
30
|
+
return r.typeMismatchEmail;
|
|
31
|
+
if (e.type === "url")
|
|
32
|
+
return r.typeMismatchUrl;
|
|
25
33
|
}
|
|
26
|
-
if (
|
|
27
|
-
if (
|
|
28
|
-
return
|
|
29
|
-
if (
|
|
30
|
-
return
|
|
34
|
+
if (e.validity.badInput) {
|
|
35
|
+
if (e.type === "number")
|
|
36
|
+
return r.badInputNumber;
|
|
37
|
+
if (e.type === "date")
|
|
38
|
+
return r.badInputDate;
|
|
31
39
|
}
|
|
32
|
-
if (
|
|
33
|
-
return
|
|
34
|
-
if (
|
|
35
|
-
const
|
|
36
|
-
return
|
|
40
|
+
if (e.validity.patternMismatch)
|
|
41
|
+
return r.patternMismatch;
|
|
42
|
+
if (e.validity.stepMismatch) {
|
|
43
|
+
const t = Math.floor(Number(e.value) / Number(e.step)) * Number(e.step), d = Math.ceil(Number(e.value) / Number(e.step)) * Number(e.step);
|
|
44
|
+
return r.stepMismatch(t, d);
|
|
37
45
|
}
|
|
38
|
-
return
|
|
46
|
+
return e.validity.customError ? e.validationMessage : null;
|
|
39
47
|
}
|
|
40
|
-
function n(
|
|
41
|
-
|
|
48
|
+
function n(e) {
|
|
49
|
+
e.target !== null && (i.value = o(e.target));
|
|
42
50
|
}
|
|
43
|
-
function
|
|
44
|
-
return
|
|
51
|
+
function m() {
|
|
52
|
+
return i.value;
|
|
45
53
|
}
|
|
46
54
|
return {
|
|
47
55
|
onInvalid: n,
|
|
48
|
-
getInvalidMessage:
|
|
56
|
+
getInvalidMessage: m,
|
|
49
57
|
setCustomError: l
|
|
50
58
|
};
|
|
51
59
|
}
|
|
52
60
|
export {
|
|
53
|
-
|
|
61
|
+
g as useValidator
|
|
54
62
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zemkogabor/vue-form-validator",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A lightweight Vue.js library that implements the JavaScript Constraint Validation API, offering advanced form validation with custom error messages and internationalization support.",
|
|
5
5
|
"module": "./dist/vue-form-validator.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -32,28 +32,28 @@
|
|
|
32
32
|
],
|
|
33
33
|
"author": "Gabor Zemko <gaborzemko@gmail.com>",
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"vue": "^3.0.0"
|
|
36
|
-
"vue-i18n": "^9.0.0"
|
|
35
|
+
"vue": "^3.0.0"
|
|
37
36
|
},
|
|
38
37
|
"devDependencies": {
|
|
39
|
-
"@
|
|
40
|
-
"@tsconfig/
|
|
41
|
-
"@types/
|
|
42
|
-
"@
|
|
43
|
-
"@vue/eslint-config-typescript": "^
|
|
44
|
-
"@vue/tsconfig": "^0.
|
|
45
|
-
"
|
|
38
|
+
"@eslint/js": "^9.39.2",
|
|
39
|
+
"@tsconfig/node22": "^22.0.5",
|
|
40
|
+
"@types/bootstrap": "^5.2.10",
|
|
41
|
+
"@types/node": "^22.10.1",
|
|
42
|
+
"@vue/eslint-config-typescript": "^14.6.0",
|
|
43
|
+
"@vue/tsconfig": "^0.8.1",
|
|
44
|
+
"@vitejs/plugin-vue": "^6.0.3",
|
|
45
|
+
"eslint": "^9.39.2",
|
|
46
46
|
"eslint-config-standard": "^17.1.0",
|
|
47
|
-
"eslint-plugin-import": "^2.
|
|
48
|
-
"eslint-plugin-n": "^
|
|
47
|
+
"eslint-plugin-import": "^2.32.0",
|
|
48
|
+
"eslint-plugin-n": "^17.23.1",
|
|
49
49
|
"eslint-plugin-node": "^11.1.0",
|
|
50
|
-
"eslint-plugin-promise": "^
|
|
51
|
-
"eslint-plugin-vue": "^
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"vue": "^3.
|
|
56
|
-
"
|
|
57
|
-
"
|
|
50
|
+
"eslint-plugin-promise": "^7.2.1",
|
|
51
|
+
"eslint-plugin-vue": "^10.6.2",
|
|
52
|
+
"lint-staged": "^16.2.7",
|
|
53
|
+
"typescript-eslint": "^8.52.0",
|
|
54
|
+
"vue-tsc": "^3.2.2",
|
|
55
|
+
"vue": "^3.5.27",
|
|
56
|
+
"vite": "^7.3.1",
|
|
57
|
+
"vite-plugin-dts": "^4.5.4"
|
|
58
58
|
}
|
|
59
59
|
}
|
package/dist/Validator.d.ts
DELETED
package/dist/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useValidator } from './Validator';
|