@zemkogabor/vue-form-validator 0.0.2 → 1.0.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/README.md CHANGED
@@ -3,7 +3,13 @@
3
3
  A lightweight Vue.js library that implements the JavaScript Constraint Validation API,
4
4
  offering advanced form validation with custom error messages and internationalization support.
5
5
 
6
- Examples see [here](https://github.com/zemkogabor/vue-form-validator/blob/main/dev/App.vue).
6
+ ## Usage
7
+ ```
8
+ yarn add @zemkogabor/vue-form-validator
7
9
 
10
+ or
8
11
 
12
+ npm install @zemkogabor/vue-form-validator
13
+ ```
9
14
 
15
+ Examples see [here](https://github.com/zemkogabor/vue-form-validator/blob/main/dev/App.vue).
@@ -1,52 +1,51 @@
1
1
  import { ref as v } from "vue";
2
- import { useI18n as m } from "vue-i18n";
3
- function c(i) {
4
- const { t: e } = m(), t = v(null);
5
- function l(r) {
6
- const a = i.value;
7
- a !== null && (r !== null ? a.setCustomValidity(r) : a.setCustomValidity(""), t.value = o(a));
2
+ function c(l, t) {
3
+ const a = v(null);
4
+ function n(r) {
5
+ const e = l.value;
6
+ e !== null && (r !== null ? e.setCustomValidity(r) : e.setCustomValidity(""), a.value = i(e));
8
7
  }
9
- function o(r) {
8
+ function i(r) {
10
9
  if (r.validity.valueMissing)
11
- return e("validator.error.value_missing");
10
+ return t.valueMissing;
12
11
  if (r.validity.tooShort)
13
- return e("validator.error.too_short", [r.minLength]);
12
+ return t.tooShort(r.minLength);
14
13
  if (r.validity.tooLong)
15
- return e("validator.error.too_long", [r.maxLength]);
14
+ return t.tooLong(r.maxLength);
16
15
  if (r.validity.rangeUnderflow)
17
- return e("validator.error.range_underflow", [r.min]);
16
+ return t.rangeUnderflow(r.min);
18
17
  if (r.validity.rangeOverflow)
19
- return e("validator.error.range_overflow", [r.max]);
18
+ return t.rangeOverflow(r.max);
20
19
  if (r.validity.typeMismatch) {
21
20
  if (r.type === "email")
22
- return e("validator.error.type_mismatch.email");
21
+ return t.typeMismatchEmail;
23
22
  if (r.type === "url")
24
- return e("validator.error.type_mismatch.url");
23
+ return t.typeMismatchUrl;
25
24
  }
26
25
  if (r.validity.badInput) {
27
26
  if (r.type === "number")
28
- return e("validator.error.bad_input.number");
27
+ return t.badInputNumber;
29
28
  if (r.type === "date")
30
- return e("validator.error.bad_input.date");
29
+ return t.badInputDate;
31
30
  }
32
31
  if (r.validity.patternMismatch)
33
- return e("validator.error.pattern_mismatch");
32
+ return t.patternMismatch;
34
33
  if (r.validity.stepMismatch) {
35
- const a = Math.floor(Number(r.value) / Number(r.step)) * Number(r.step), d = Math.ceil(Number(r.value) / Number(r.step)) * Number(r.step);
36
- return e("validator.error.step_mismatch", [a, d]);
34
+ const e = Math.floor(Number(r.value) / Number(r.step)) * Number(r.step), u = Math.ceil(Number(r.value) / Number(r.step)) * Number(r.step);
35
+ return t.stepMismatch(e, u);
37
36
  }
38
37
  return r.validity.customError ? r.validationMessage : null;
39
38
  }
40
- function n(r) {
41
- r.target !== null && (t.value = o(r.target));
39
+ function o(r) {
40
+ r.target !== null && (a.value = i(r.target));
42
41
  }
43
- function s() {
44
- return t.value;
42
+ function f() {
43
+ return a.value;
45
44
  }
46
45
  return {
47
- onInvalid: n,
48
- getInvalidMessage: s,
49
- setCustomError: l
46
+ onInvalid: o,
47
+ getInvalidMessage: f,
48
+ setCustomError: n
50
49
  };
51
50
  }
52
51
  export {
package/package.json CHANGED
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "name": "@zemkogabor/vue-form-validator",
3
- "version": "0.0.2",
3
+ "version": "1.0.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
+ "types": "./dist/index.d.ts",
6
7
  "type": "module",
7
8
  "exports": {
8
9
  ".": {
9
- "import": "./dist/vue-form-validator.js"
10
+ "import": "./dist/vue-form-validator.js",
11
+ "types": "./dist/index.d.ts"
10
12
  }
11
13
  },
12
14
  "files": [
@@ -30,27 +32,28 @@
30
32
  ],
31
33
  "author": "Gabor Zemko <gaborzemko@gmail.com>",
32
34
  "peerDependencies": {
33
- "vue": "^3.0.0",
34
- "vue-i18n": "^9.0.0"
35
+ "vue": "^3.0.0"
35
36
  },
36
37
  "devDependencies": {
37
- "@rushstack/eslint-patch": "^1.3.3",
38
- "@tsconfig/node20": "^20.1.2",
39
- "@types/node": "^20.11.10",
40
- "@vitejs/plugin-vue": "^5.0.3",
41
- "@vue/eslint-config-typescript": "^12.0.0",
42
- "@vue/tsconfig": "^0.5.1",
43
- "eslint": "^8.49.0",
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",
44
46
  "eslint-config-standard": "^17.1.0",
45
- "eslint-plugin-import": "^2.29.1",
46
- "eslint-plugin-n": "^16.6.2",
47
+ "eslint-plugin-import": "^2.32.0",
48
+ "eslint-plugin-n": "^17.23.1",
47
49
  "eslint-plugin-node": "^11.1.0",
48
- "eslint-plugin-promise": "^6.1.1",
49
- "eslint-plugin-vue": "^9.22.0",
50
- "typescript": "~5.3.0",
51
- "vite": "^5.0.11",
52
- "vue-i18n": "^9.10.1",
53
- "vue": "^3.4.21",
54
- "vue-tsc": "^1.8.27"
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"
55
58
  }
56
59
  }