From efbe4e7b0e65f8be798444ef52c7764cd30a3473 Mon Sep 17 00:00:00 2001 From: Alexis Tyler Date: Wed, 3 Mar 2021 14:26:32 +1030 Subject: [PATCH] chore: remove upcast --- app/core/utils/casting.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/core/utils/casting.ts b/app/core/utils/casting.ts index 18de37856..d4a84ffda 100644 --- a/app/core/utils/casting.ts +++ b/app/core/utils/casting.ts @@ -1,7 +1,6 @@ -import { upcast } from './upcast'; - -export const toBoolean = (value: any): boolean => upcast.to(value, 'boolean'); -export const toNumber = (value: any): number => upcast.to(value, 'number'); +// If it's "true", "yes" or "1" then it's true otherwise it's false +export const toBoolean = (value: string): boolean => value.toLowerCase().trim() === 'true' || value.toLowerCase().trim() === 'yes' || value === '1'; +export const toNumber = (value: string): number => parseInt(value, 10); type BooleanString = 'true' | 'false';