WIP: Anmeldeformular #16

Closed
alioezdemir wants to merge 9 commits from Anmeldeformular into main
2 changed files with 1 additions and 5 deletions
Showing only changes of commit c971e4dddc - Show all commits

View File

@ -204,7 +204,7 @@
mat-button
matStepperNext
[disabled]="thirdFormGroup.status == 'INVALID'"
(click)="onClick()">
>
Submit
</button>
</div>

View File

@ -121,10 +121,6 @@ export class StudentRegisterComponent implements OnInit {
});
}
onClick() {
console.log(this.zeroFormGroup);
}
// Custom validator function
requireAtLeastOne(formGroup: FormGroup) {
Review

D-R-Y

requireAtLeastOne(formGroup: FormGroup): ValidationErrors | null {
  const controls = Object.keys(formGroup.controls);

  // Prüfe, ob mindestens ein Wert gesetzt ist
  const isAnyFieldFilled = controls.some(key => {
    const value = formGroup.get(key)?.value;
    return value !== null && value !== '';
  });

  return isAnyFieldFilled ? null : { requiredAtLeastOne: true };
}
D-R-Y ``` requireAtLeastOne(formGroup: FormGroup): ValidationErrors | null { const controls = Object.keys(formGroup.controls); // Prüfe, ob mindestens ein Wert gesetzt ist const isAnyFieldFilled = controls.some(key => { const value = formGroup.get(key)?.value; return value !== null && value !== ''; }); return isAnyFieldFilled ? null : { requiredAtLeastOne: true }; } ```
const danceTraining = formGroup.get('danceTraining')?.value;