refactor(error): move error types to centralized location
Consolidate XError, XErrors, and FormErrors types into a single file for better maintainability and consistency across the codebase.
This commit is contained in:
No files matched your search
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { FormErrors } from '~/composables/useFormErrors'
|
import type { FormErrors } from '~/types/error'
|
||||||
import Block from '~/components/pub/custom-ui/form/block.vue'
|
import Block from '~/components/pub/custom-ui/form/block.vue'
|
||||||
import Combobox from '~/components/pub/custom-ui/form/combobox.vue'
|
import Combobox from '~/components/pub/custom-ui/form/combobox.vue'
|
||||||
import FieldGroup from '~/components/pub/custom-ui/form/field-group.vue'
|
import FieldGroup from '~/components/pub/custom-ui/form/field-group.vue'
|
||||||
|
|||||||
@@ -1,13 +1,5 @@
|
|||||||
import type { ZodError } from 'zod'
|
import type { ZodError } from 'zod'
|
||||||
|
import type { FormErrors } from '~/types/error'
|
||||||
export interface XError {
|
|
||||||
message: string
|
|
||||||
[key: string]: any
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface FormErrors {
|
|
||||||
[field: string]: XError
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Composable untuk menangani form validation errors seperti Laravel
|
* Composable untuk menangani form validation errors seperti Laravel
|
||||||
|
|||||||
@@ -1,13 +1,5 @@
|
|||||||
import type { Pinia } from 'pinia'
|
import type { Pinia } from 'pinia'
|
||||||
|
import type { XError, XErrors } from '~/types/error'
|
||||||
export interface XError {
|
|
||||||
code: string
|
|
||||||
message: string
|
|
||||||
expectedVal?: string
|
|
||||||
givenVal?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export type XErrors = Record<string, XError>
|
|
||||||
|
|
||||||
export interface XfetchResult {
|
export interface XfetchResult {
|
||||||
success: boolean
|
success: boolean
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* Base interface untuk error yang digunakan di seluruh aplikasi
|
||||||
|
*/
|
||||||
|
export interface XError {
|
||||||
|
/** Pesan error yang akan ditampilkan */
|
||||||
|
message: string
|
||||||
|
/** Kode error (opsional) */
|
||||||
|
code?: string
|
||||||
|
/** Nilai yang diharapkan (untuk validasi) */
|
||||||
|
expectedVal?: string
|
||||||
|
/** Nilai yang diberikan (untuk validasi) */
|
||||||
|
givenVal?: string
|
||||||
|
/** Path field yang error (untuk form validation) */
|
||||||
|
path?: (string | number)[]
|
||||||
|
/** Properties tambahan lainnya */
|
||||||
|
[key: string]: any
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collection of errors dengan key sebagai field name
|
||||||
|
*/
|
||||||
|
export type XErrors = Record<string, XError>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Form errors type alias untuk kompatibilitas
|
||||||
|
*/
|
||||||
|
export type FormErrors = XErrors
|
||||||
Reference in New Issue
Block a user