Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass errors as a prop to the wrapped component #124

Open
mtrunt opened this issue May 29, 2022 · 0 comments
Open

Pass errors as a prop to the wrapped component #124

mtrunt opened this issue May 29, 2022 · 0 comments

Comments

@mtrunt
Copy link

mtrunt commented May 29, 2022

I'm using VFJS with Vuetify and I would like to pass vfjsFieldErrors as the error-messages prop to Vuetify's VTextField component.

As far as I know, I could create a wrapper component for the uiSchema and map vfjsFieldErrors to error-messages prop; however what I was thinking is since setting errorHandler as true on a component already gets the error messages as an array and passes them as children, could it be possible to add an option to pass down the errors as a prop to the component instead?

I was thinking something like this:

{
  component: 'v-text-field',
  model: key,
  fieldOptions: {
     ...
  },
  errorOptions: {
    class: ['is-invalid'],
    // If this key is found transform the errors the same was as if `errorHandler: true`
    errorAsProp: 'error-messages'
    // Optionally a mapper can be defined that would receive `ajv` errors array and you can
    // transform them however you want
    errorMapper: (errors) => ...
  },
}

Maybe I'm missing something and there's an easier way to accomplish this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant