From 2bfeb850133c8a86922e3e9a497f97cf7f1c80b8 Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Mon, 24 Oct 2022 10:18:51 +0100 Subject: [PATCH] Make NaN undefined --- packages/builder/src/helpers/helpers.js | 7 ++++++- packages/builder/src/helpers/validation/yup/index.js | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/helpers/helpers.js b/packages/builder/src/helpers/helpers.js index 9b0fa51a52..72c034d9a6 100644 --- a/packages/builder/src/helpers/helpers.js +++ b/packages/builder/src/helpers/helpers.js @@ -17,7 +17,12 @@ export const convertCamel = str => { export const pipe = (arg, funcs) => flow(funcs)(arg) -export const capitalise = s => s.substring(0, 1).toUpperCase() + s.substring(1) +export const capitalise = s => { + if (!s) { + return s + } + return s.substring(0, 1).toUpperCase() + s.substring(1) +} export const lowercase = s => s.substring(0, 1).toLowerCase() + s.substring(1) diff --git a/packages/builder/src/helpers/validation/yup/index.js b/packages/builder/src/helpers/validation/yup/index.js index 9b38adbf9d..c064ffa583 100644 --- a/packages/builder/src/helpers/validation/yup/index.js +++ b/packages/builder/src/helpers/validation/yup/index.js @@ -28,7 +28,9 @@ export const createValidationStore = () => { let propertyValidator switch (type) { case "number": - propertyValidator = number() + propertyValidator = number().transform(value => + isNaN(value) ? undefined : value + ) break case "email": propertyValidator = string().email()