diff --git a/services/frontend/src/utils/forms.ts b/services/frontend/src/utils/forms.ts index 560ea3b..26cd41d 100644 --- a/services/frontend/src/utils/forms.ts +++ b/services/frontend/src/utils/forms.ts @@ -1,4 +1,5 @@ import lodash from "lodash"; +import { number } from "yup"; export const checkArray = (array: any, name: string): T => { if (!Array.isArray(array)) { @@ -32,6 +33,19 @@ export const pruneString = (value?: string): string | undefined => { return value; }; +export const pruneNumber = (value?: number): number | undefined => { + if ( + value === undefined || + value === null || + isNaN(value) || + (value as unknown as string) === "" + ) { + return undefined; + } + + return value; +}; + export const splitKVPairs = ( text: string, seperator: string,