Skip to content

Commit

Permalink
Attempt fix for validation errors object and add install as vue plugi…
Browse files Browse the repository at this point in the history
…n option
  • Loading branch information
Thavarshan committed Nov 15, 2024
1 parent 7e371c0 commit 484b6ec
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export class Form<TForm extends NestedFormData<TForm>> implements IForm<TForm> {
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
}),
{}
);
Expand Down
11 changes: 11 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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';

0 comments on commit 484b6ec

Please sign in to comment.