mktcms 0.1.42 → 0.1.43

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/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mktcms",
3
3
  "configKey": "mktcms",
4
- "version": "0.1.42",
4
+ "version": "0.1.43",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -5,6 +5,7 @@ export declare function useForm(endpoint: string, successMessageText: string, er
5
5
  errorMessage: import("vue").Ref<string, string>;
6
6
  validationErrors: import("vue").Ref<Record<string, string[] | undefined>, Record<string, string[] | undefined>>;
7
7
  fieldsTouched: import("vue").Ref<Record<string, boolean>, Record<string, boolean>>;
8
+ isValid: import("vue").ComputedRef<boolean>;
8
9
  validationErrorsFor: (field: string) => string[];
9
10
  validate: (body: Record<string, any>) => boolean;
10
11
  touchField: (field: string) => void;
@@ -1,11 +1,12 @@
1
1
  import { z } from "zod";
2
- import { ref } from "vue";
2
+ import { computed, ref } from "vue";
3
3
  export function useForm(endpoint, successMessageText, errorMessageText, validationSchema) {
4
4
  const isSending = ref(false);
5
5
  const successMessage = ref("");
6
6
  const errorMessage = ref("");
7
7
  const validationErrors = ref({});
8
8
  const fieldsTouched = ref({});
9
+ const isValid = computed(() => Object.keys(validationErrors.value).length === 0 && Object.keys(fieldsTouched.value).length > 0);
9
10
  function validate(body) {
10
11
  const parseResult = validationSchema.safeParse(body);
11
12
  if (parseResult.success) {
@@ -52,6 +53,7 @@ export function useForm(endpoint, successMessageText, errorMessageText, validati
52
53
  errorMessage,
53
54
  validationErrors,
54
55
  fieldsTouched,
56
+ isValid,
55
57
  validationErrorsFor,
56
58
  validate,
57
59
  touchField,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mktcms",
3
- "version": "0.1.42",
3
+ "version": "0.1.43",
4
4
  "description": "Simple CMS module for Nuxt",
5
5
  "repository": "mktcode/mktcms",
6
6
  "license": "MIT",