Vue-form-generator: Global custom validators

Created on 6 Nov 2018  ·  3Comments  ·  Source: vue-generators/vue-form-generator

  • I'm submitting a ...

    • [ ] bug report
    • [x] feature request
    • [ ] support request
  • Do you want to request a _feature_ or report a _bug_?

I want to request a feature.

  • What is the current behavior?

Right now, there is a limited number of global field validators that come predefined with the plugin.

  • What is the motivation / use case for changing the behavior?

Validators included by default do not cover a sufficient variety of possible validation criteria. For example, there is no validator that would require the user to 'check' a checkbox element (validating a value to be true).

Currently, this functionality can be extended by passing custom functions to the validator field in the schema object, but this is a deviation from the API used for default validators (passing them as a string array). My feature proposal is to give developers the ability to pass their custom validators in the Vue.use(VueFormGenerator, ....) plugin inclusion call alongside custom fields. These validators could then be accessed in the schema under the validator array the same way predefined validators are.

enhancement medium v3

Most helpful comment

Not a bad request... and implementing a way to import custom validators in the init options seems like a good way to go.

However, in the mean time, you can inject them directly ....

VueFormGenerator.validators.customFunc = () = {};

Then just reference “customFunc” in the string array.

All 3 comments

Not a bad request... and implementing a way to import custom validators in the init options seems like a good way to go.

However, in the mean time, you can inject them directly ....

VueFormGenerator.validators.customFunc = () = {};

Then just reference “customFunc” in the string array.

@zwx00 how's this PR look?

Looks good, thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sjordan1975 picture sjordan1975  ·  5Comments

icebob picture icebob  ·  4Comments

afourmeaux picture afourmeaux  ·  4Comments

ndro picture ndro  ·  4Comments

jaywilburn picture jaywilburn  ·  3Comments