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

added "options" to VFG install function, appending custom "validators… #560

Merged

Conversation

zoul0813
Copy link
Member

…" to the validators object that are passed into `Vue.use(VueFormGenerator, { validators: { key: (value, field, model) => {} })

  • Please check if the PR fulfills these requirements
  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
    Feature
  • What is the current behavior? (You can also link to an open issue here)
    VFG has a limited number of "built-in" validators, and custom validators require a reference to the function which is not possible when using JSON returned from the server.
  • What is the new behavior (if this is a feature change)?
    Introduce the ability to modify the "built-in validators" when calling Vue.use(VueFormGenerator) by passing an options object with the validators.
  • Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
    No

Example usage:

import Vue from "vue";
import VueFormGenerator from "../../../src";
Vue.use(VueFormGenerator, {
	validators: {
		customValidator: (value, field, model) => {
			console.log("customValidator", value, field, model);
			return true;
		}
	}
});

import App from "./app.vue";

new Vue({
	...App
}).$mount("#app");

…" to the validators object that are passed into `Vue.use(VueFormGenerator, { validators: { key: (value, field, model) => {} })
@zoul0813
Copy link
Member Author

@lionel-bijaoui I was thinking that the install method may be a good place to define some general purpose defaults as well, such as default formOptions.

It may also be a nice place to be able to enable/disable certain field types ... say for example, you don't want to allow your forms to use 'selectEx', 'pikaday', 'masked', etc ... we can add some sort of support for disabling them?

@coveralls
Copy link

coveralls commented Dec 10, 2018

Coverage Status

Coverage remained the same at 89.916% when pulling 4e81d2d on zoul0813:feature/545-vue-use-validators into a484031 on vue-generators:master.

@zoul0813
Copy link
Member Author

docs added in vue-generators/vue-form-generator-docs#4

@zoul0813 zoul0813 merged commit 862ebd8 into vue-generators:master Dec 14, 2018
@zoul0813 zoul0813 deleted the feature/545-vue-use-validators branch December 14, 2018 18:07
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

Successfully merging this pull request may close these issues.

Global custom validators
2 participants