From 5864628be39e7563f2a91f24a6f92079bc655614 Mon Sep 17 00:00:00 2001 From: jojohoch <joachim.hoch@iqb.hu-berlin.de> Date: Thu, 29 Jul 2021 10:39:51 +0200 Subject: [PATCH] [player] Add `requiredTrue` validator for checkboxes --- .../src/app/components/validation-message.component.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/projects/player/src/app/components/validation-message.component.ts b/projects/player/src/app/components/validation-message.component.ts index a54bd954d..9170750c6 100644 --- a/projects/player/src/app/components/validation-message.component.ts +++ b/projects/player/src/app/components/validation-message.component.ts @@ -14,6 +14,9 @@ import { FormService } from '../../../../common/form.service'; <mat-error *ngIf="formElementControl.errors?.required"> {{requiredMessage}} </mat-error> + <mat-error *ngIf="formElementControl.errors?.requiredTrue"> + {{requiredMessage}} + </mat-error> <mat-error *ngIf="formElementControl.errors?.minlength"> {{minLengthMessage}} </mat-error> @@ -49,7 +52,11 @@ export class ValidationMessageComponent implements OnInit { private get validators(): ValidatorFn[] { const validators: ValidatorFn[] = []; if (this.elementModel.required) { - validators.push(Validators.required); + if (this.elementModel.type === 'checkbox') { + validators.push(Validators.requiredTrue); + } else { + validators.push(Validators.required); + } } if (this.elementModel.min) { if (this.elementModel.type === 'number-field') { -- GitLab