Skip to content

Commit

Permalink
Set default for errorName in isNumberRange validator
Browse files Browse the repository at this point in the history
  • Loading branch information
reiterl committed Dec 19, 2024
1 parent 0c0f861 commit 32d6636
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
]
Expand Down

0 comments on commit 32d6636

Please sign in to comment.