From 32d66368b2fc192664343fd2f3c2b37844b64d16 Mon Sep 17 00:00:00 2001 From: Ludwig Reiter Date: Thu, 19 Dec 2024 10:45:55 +0100 Subject: [PATCH] Set default for errorName in isNumberRange validator --- .../src/app/infrastructure/utils/validators/is-number-range.ts | 2 +- .../src/app/infrastructure/utils/validators/validators.spec.ts | 2 +- .../poll/components/base-poll-form/base-poll-form.component.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/src/app/infrastructure/utils/validators/is-number-range.ts b/client/src/app/infrastructure/utils/validators/is-number-range.ts index 0c8b3795d7..5606d2b24a 100644 --- a/client/src/app/infrastructure/utils/validators/is-number-range.ts +++ b/client/src/app/infrastructure/utils/validators/is-number-range.ts @@ -1,6 +1,6 @@ import { AbstractControl, ValidatorFn } from '@angular/forms'; -export function isNumberRange(minCtrlName: string, maxCtrlName: string, errorName: string): ValidatorFn { +export function isNumberRange(minCtrlName: string, maxCtrlName: string, errorName: string = `rangeError`): ValidatorFn { return (formControl: AbstractControl): { [key: string]: any } | null => { const min = formControl.get(minCtrlName)!.value; const max = formControl.get(maxCtrlName)!.value; diff --git a/client/src/app/infrastructure/utils/validators/validators.spec.ts b/client/src/app/infrastructure/utils/validators/validators.spec.ts index 03ca2a6a6e..fcd16f8fc9 100644 --- a/client/src/app/infrastructure/utils/validators/validators.spec.ts +++ b/client/src/app/infrastructure/utils/validators/validators.spec.ts @@ -5,7 +5,7 @@ import { isUniqueAmong } from './is-unique-among'; describe(`utils: validators`, () => { describe(`isNumberRange function`, () => { - const validatorFn = isNumberRange(`min`, `max`, `errorName`); + const validatorFn = isNumberRange(`min`, `max`); it(`test with correct values`, () => { const group = new UntypedFormGroup( { diff --git a/client/src/app/site/pages/meetings/modules/poll/components/base-poll-form/base-poll-form.component.ts b/client/src/app/site/pages/meetings/modules/poll/components/base-poll-form/base-poll-form.component.ts index 982fdd2e06..b55940abad 100644 --- a/client/src/app/site/pages/meetings/modules/poll/components/base-poll-form/base-poll-form.component.ts +++ b/client/src/app/site/pages/meetings/modules/poll/components/base-poll-form/base-poll-form.component.ts @@ -473,7 +473,7 @@ export abstract class BasePollFormComponent extends BaseComponent implements OnI }, { validators: [ - isNumberRange(`min_votes_amount`, `max_votes_amount`, `rangeError`), + isNumberRange(`min_votes_amount`, `max_votes_amount`), this.enoughPollOptionsAvailable(`min_votes_amount`, `max_votes_per_option`), isNumberRange(`max_votes_per_option`, `max_votes_amount`, `rangeErrorMaxPerOption`) ]