question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Validate child components

See original GitHub issue

Versions

  • vee-validate: 2.2.10
  • vue: 2.6.10

Describe the bug If I add a component to my form, which has an input that should be required, the validation result is always true.

To reproduce

This is from the parent component:

 <component
    :name="'field-value'"
    v-model="newField.value"
    :is="newField.value">
</component>

This is the child component:

<template>
        <b-input
                :id="'form-'+name"
                :name="'form-'+name"
                type="number"
                v-validate="'required|numeric'"
                :state="errors.has('form-modal.form-'+name) ? 'invalid' : ''"
                :value="value"
                v-on:input="$emit('input',$event)"/>
</template>
<script>
export default {
	name: 'Integer',
	inject: ['$validator'],
	props: ['name', 'value'],
}
</script>

This is the parent validation:

this.$validator.validateAll ('form-modal').then ((result) => {

	if (result) {
		//do stuff
		this.$validator.reset ();
		this.$refs.modal.hide ();
	}
});

Expected behavior If the field is empty, no error is being shown. All other validations in the modal are working fine.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
Loremastercommented, Jan 30, 2020

@pwgardipee did you find a solution?

2reactions
pwgardipeecommented, Jan 12, 2020

@logaretm How can I use ValidationProvider and ValidationObserver to do the validation on a child from the parent? I have recently migrated to v3.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Child Component Validation - CodeSandbox
Child Component Validation. Vuelidate child component validation. ... Forked FromCustom Validator; Environmentvue-cli. Files. src. assets. components.
Read more >
How to validate input in child component - angular
If you want your components to be "understandable" by a form, they must first implement interface ControlValueAccessor in order to be considered ...
Read more >
Custom Validations between Child, Parent ... - Salesforce Bolt
In this blog you will learn how you may use validation between Child, Parent and Grandparent component. The requirement was to have a...
Read more >
Angular Reactive Forms in parent-child components
The parent component will have the FormModel with all the validations, either those are built-in, custom, async or dynamic validators.
Read more >
Validate a Telerik component as child component and apply ...
Internally, the Telerik Blazor components use the cascading EditContext parameter that the EditForm provides to determine if validation passes or fails. If it ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found