diff --git a/package.json b/package.json index bc83cf5..958613d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "formlink", "description": "Laravel-Vue form helper library.", - "version": "2.0.0", + "version": "1.2.4", "type": "module", "author": { "name": "Jerome Thayananthajothy", diff --git a/src/form.ts b/src/form.ts index b448bd7..d88af4f 100644 --- a/src/form.ts +++ b/src/form.ts @@ -268,7 +268,7 @@ export class Form> implements IForm { this.errors = Object.entries(validationError.errors).reduce( (acc, [key, messages]) => ({ ...acc, - [key]: messages + [key]: Array.isArray(messages) ? messages[0] : messages // Use the first error message if it's an array }), {} ); diff --git a/src/index.ts b/src/index.ts index e37e166..5ecafa7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,2 +1,13 @@ +import { App } from 'vue'; +import { Form } from './form'; +import { useForm } from './use-form'; + +const install = (app: App) => { + app.component('Form', Form); + app.config.globalProperties.$useForm = useForm; +}; + +export default { install }; + export { Form } from './form'; export { useForm } from './use-form';