I need to validate that my user selects at least one viewport. I simply added the validator.required for the input but for the checkbox in an array I am not sure how to validate it.
public createForm(): FormGroup {
return this.formBuilder.group({
urlInput: ['', [ Validators.required, Validators.pattern(URL_VALIDATOR) ]],
children: [false, []],
viewport: this.formBuilder.array(this.viewports.map(x => false))
});
}
I used this to create the checkbox:
public ngOnInit(): void {
this.urlForm = this.createForm();
const checkboxControl = this.urlForm.controls.viewport as FormArray;