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

Validation concept? #682

Open
2 tasks
CaptainCannabis opened this issue Jul 27, 2020 · 1 comment
Open
2 tasks

Validation concept? #682

CaptainCannabis opened this issue Jul 27, 2020 · 1 comment

Comments

@CaptainCannabis
Copy link

  • I'm submitting a ...

    • bug report
    • feature request
    • [ x] support request => Please do not submit support request here, see note at the top of this template.
  • What is the current behavior?

I got a form with a couple of different fields, a datepicker and a input with cleave format and so on. Each field is set to required=true and has at least one validation function which is defined in scope.

The form validation settings are

                validateAfterLoad : false,
                validateAfterChanged : true,

When i enter the form there are at least two emtpy inputs which have validation rules. I change the first of those an the formIsValidated event will run through. But it only checks the currently changed inputs. It is not iterating over the form. If i call the vfg.validate() manualy in that moment i get error messages on all invalid fields. What am i doing wrong?

  • What is the expected behavior?

I would expect that each time a field changes all fields of that form are validated,n not only the currently changed one.

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

There could be more validation errors and the visibility of my submit button is coupled to the result of formValidation. That wont work with the actual situation.

  • Please tell us about your environment:

latest version of vfg (not 3)

@CaptainCannabis
Copy link
Author

CaptainCannabis commented Jul 28, 2020

I dont get why there are separate events for form and single field validation which are emitted as the same event "validated" without a property to distinguish which is sender.

EDIT: I guess my scenario is the "edge case" here but it would be nice to have more control over the validation concept. A flag for "should i validate the other inuts on change" would be nice. Atm i solved my case by setting validateAfterLoad and validateAfterChanged to false. In the parent component of the vfg-form i add an eventListener for all of the inputs of the form which calls "self.$children[0].vfg.validate();"

Another thing i noticed is that the cleave-input wont update the model-value if you cut it out. This won't trigger the "input"-event. See

this.$el.removeEventListener("input", this.inputChange);

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