store/resources/js/lib/form.ts

13 lines
242 B
TypeScript

export interface FormWithErrors {
errors: Record<string, string | undefined>;
}
export function formErrors(
form: FormWithErrors,
key: string,
): string[] {
const error = form.errors[key];
return error ? [error] : [];
}