I am looking to set a minlength validator on a formArray element.
Here's how I created the form.
this.fb.group({
FieldName: ['', [Validators.required, Validators.pattern(/^\S*/)]],
Treatment: '',
Properties: this.fb.group(
{
contentType: this.fb.array([]),
multipleItems: false,
keyType: this.fb.group({
'Type': '',
'Prefix': '',
'Suffix': ''
}),
}
)
});
This is the code I am trying. It doesn't get applied, and the form totally ignores this and becomes valid.
this.fieldForm.get('Properties.contentType').setValidators([Validators.required, Validators.minLength(1)]);