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.

FormArray length validation in NgxSubFormComponent doesn´t propagate validity

See original GitHub issue

Hi!, firstly thank you for making angular forms better.

I think I found a bug, please look at this stackblitz: https://stackblitz.com/edit/ngx-subform-array-validation

specifically at the child-form.component, I´m using a validation function to validate FormArray length.

protected getFormControls(): Controls<ChildForm> {
        return {
            values: new FormArray([], this.minLengthArray(3)),
        };
    }

    minLengthArray(min: number) {
        return (c: AbstractControl): { [key: string]: any } => {
            if (c.value.length >= min)
                return null;

            return { 'minLengthArray': true };
        }
    }

When I delete an ítem from the array, the root form and subform should be in an invalid state, but the validation error is not propagating to the parent, only the subform is invalid

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:27 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
maxime1992commented, Jun 23, 2022

I’ve got a bunch of work to focus on so not sure I’ll be able to before end of week

I do keep it in mind and will try to have a look worst case scenario during the weekend

1reaction
anschmcommented, Jun 21, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Validate FormArray length in angular2 - Stack Overflow
I want to add validations to the place formArray, so i am adding minlength validation, but minlength validation is not working on formArray....
Read more >
FormArray - Angular
Tracks the value and validity state of an array of FormControl ... set the value of a control that doesn't exist or if...
Read more >
ReactiveForms, FormArrays and Custom Validators
Adding validations just in the template is hard to understand and maintain. In this post we will: Implement a ReactiveForm; Add and remove ......
Read more >
Angular Reactive Forms: Tips and Tricks | by Netanel Basal
We can also apply this option to a formGroup or a formArray . ... In such a case we don't have to use...
Read more >
A thorough exploration of Angular Forms - InDepth.Dev
A FormControl can be considered standalone if it does not belong to an ... (eg: min-max validator that makes sure that min control...
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