koumoul-dev / vuetify-jsonschema-form

Create beautiful and low-effort forms that output valid data. Published on npm as @koumoul/vjsf.
https://koumoul-dev.github.io/vuetify-jsonschema-form/latest/
MIT License
538 stars 154 forks source link

x-directives seems to be broken #426

Closed Jared-Kim closed 4 months ago

Jared-Kim commented 4 months ago

I have been trying to use x-directives to set a mask like the example seen here in the documentation https://koumoul-dev.github.io/vuetify-jsonschema-form/latest/examples/#directives. However, I can't seem to get the mask to apply, and the codepen example for this attached to the documentation does not seem to work either. Is this an issue with the x-directives feature itself or a bug in the codepen? If x-directives is in fact working, are any directives supported other than mask?

albanm commented 4 months ago

X-directives simply apply directives that are available in your app. The doc does not state it, but the example relies on v-mask. The codepen does not load v-mask which is why it is broken, but the example in the doc is not.

Jared-Kim commented 4 months ago

Thank You. Do you know if there is any way to trim whitespace from a string using x-directives?

Additionally I found that using mask like so on a string works

"test": {
      "type": "string",
      "x-directives": [
        {
          "name": "mask",
          "value": "####-##"
        }
      ]
    },

But using it on an array of strings like this doesn't seem to work. Do you know is this is an issue with x-directives, or with v-mask itself?

    "test": {
      "type": "array",
      "items": {
        "type": "string",
        "x-directives": [
          {
            "name": "mask",
            "value": "####-##"
          }
        ]
      }
    },
albanm commented 4 months ago

It is a limitation of x-directives. You could trim whitespace by writing your own directive and applying it with x-directives.

Jared-Kim commented 4 months ago

Was able to figure it out, thanks for the help