Skip to content

FormArray length validation in NgxSubFormComponent doesn´t propagate validity #161

Open
@agarzas

Description

@agarzas

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

Metadata

Metadata

Assignees

Labels

effort-1: minutesWill only take a few minutes to fix/createscope: libAnything related to the library itselftype: bug/fixThis is a bug or at least needs a fixworkaround: noneNo workaround

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions