fix: rename parseOptionalInt to parseOptionalNumber

This allows us to handle the possible errors due to non-integer numbers with joi and return more precise error messages.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2022-03-04 23:43:09 +01:00
parent 151e12a8a7
commit 45df0e6edb
7 changed files with 27 additions and 22 deletions

View file

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
@ -113,9 +113,9 @@ function transformLoglevelToInt(loglevel: Loglevel): number {
}
}
export function parseOptionalInt(value?: string): number | undefined {
export function parseOptionalNumber(value?: string): number | undefined {
if (value === undefined) {
return undefined;
}
return parseInt(value);
return Number(value);
}