Skip to content

Commit

Permalink
refactor: simplyfy constraint stringifying logic in validation utils
Browse files Browse the repository at this point in the history
  • Loading branch information
NoNameProvided committed Jan 11, 2021
1 parent a784d4b commit 6d42226
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/validation/ValidationUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 <comma><space> 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 {
Expand Down

0 comments on commit 6d42226

Please sign in to comment.