diff --git a/app/components/app/material/entry-form.vue b/app/components/app/material/entry-form.vue
index ae45edba..979c6970 100644
--- a/app/components/app/material/entry-form.vue
+++ b/app/components/app/material/entry-form.vue
@@ -3,14 +3,32 @@ import Block from '~/components/pub/custom-ui/form/block.vue'
import FieldGroup from '~/components/pub/custom-ui/form/field-group.vue'
import Field from '~/components/pub/custom-ui/form/field.vue'
import Label from '~/components/pub/custom-ui/form/label.vue'
+import { z } from 'zod'
const props = defineProps<{ modelValue: any }>()
const emit = defineEmits(['update:modelValue', 'event'])
+const schema = z.object({
+ code: z.string(),
+ name: z.string(),
+ type: z.string(),
+ stock: z.preprocess((val) => Number(val), z.number({ invalid_type_error: "Stok harus berupa angka" })),
+})
+
const data = computed({
get: () => props.modelValue,
- set: (val) => emit('update:modelValue', val),
+ set: (val) => {
+ const result = schema.safeParse(val)
+ if (!result.success) {
+ // You can handle the error here, e.g. show a message
+ const errorMessage = result.error.errors[0]?.message ?? 'Validation error occurred'
+ alert(errorMessage)
+ return
+ }
+ emit('update:modelValue', val)
+ },
})
+
const items = [
{ value: 'item1', label: 'Item 1' },
{ value: 'item2', label: 'Item 2' },
@@ -43,7 +61,7 @@ const items = [
-
+
diff --git a/package.json b/package.json
index 00158330..905dee25 100644
--- a/package.json
+++ b/package.json
@@ -67,6 +67,6 @@
"vue-router": "^4.5.1",
"vue-sonner": "^1.3.0",
"vue-tsc": "^2.1.10",
- "zod": "^3.24.2"
+ "zod": "^3.25.76"
}
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 7a3ef8de..bcbed231 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -161,7 +161,7 @@ devDependencies:
specifier: ^2.1.10
version: 2.2.12(typescript@5.9.2)
zod:
- specifier: ^3.24.2
+ specifier: ^3.25.76
version: 3.25.76
packages: