feat(frontend): created `pruneNumber` utility function

pull/85/head
Samuel Rowe 3 years ago
parent fb4d93d0b4
commit 029cf06c79

@ -1,4 +1,5 @@
import lodash from "lodash"; import lodash from "lodash";
import { number } from "yup";
export const checkArray = <T>(array: any, name: string): T => { export const checkArray = <T>(array: any, name: string): T => {
if (!Array.isArray(array)) { if (!Array.isArray(array)) {
@ -32,6 +33,19 @@ export const pruneString = (value?: string): string | undefined => {
return value; 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 = ( export const splitKVPairs = (
text: string, text: string,
seperator: string, seperator: string,

Loading…
Cancel
Save