From 6d42226df18b7cf0d772f32c927966edef7f4a3e Mon Sep 17 00:00:00 2001 From: Attila Olah Date: Mon, 11 Jan 2021 20:36:52 +0100 Subject: [PATCH] refactor: simplyfy constraint stringifying logic in validation utils --- src/validation/ValidationUtils.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/validation/ValidationUtils.ts b/src/validation/ValidationUtils.ts index 6a778e75a4..a7a674622e 100644 --- a/src/validation/ValidationUtils.ts +++ b/src/validation/ValidationUtils.ts @@ -4,13 +4,11 @@ import { ValidationArguments } from './ValidationArguments'; * Convert the constraint to a string to be shown in an error */ export function constraintToString(constraint: unknown): string { - if (typeof constraint === 'string') return constraint; - - // join array as separated values strings - if (Array.isArray(constraint)) return constraint.map(constraintToString).join(', '); + if (Array.isArray(constraint)) { + return constraint.join(', '); + } - // convert to string... - return String(constraint); + return `${ constraint }`; } export class ValidationUtils {