Skip to content

Pass errors as a prop to the wrapped component #124

@mtrunt

Description

@mtrunt

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions