Make NaN undefined

This commit is contained in:
Mel O'Hagan 2022-10-24 10:18:51 +01:00
parent 777e8f91f1
commit 2bfeb85013
2 changed files with 9 additions and 2 deletions

View File

@ -17,7 +17,12 @@ export const convertCamel = str => {
export const pipe = (arg, funcs) => flow(funcs)(arg) 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) export const lowercase = s => s.substring(0, 1).toLowerCase() + s.substring(1)

View File

@ -28,7 +28,9 @@ export const createValidationStore = () => {
let propertyValidator let propertyValidator
switch (type) { switch (type) {
case "number": case "number":
propertyValidator = number() propertyValidator = number().transform(value =>
isNaN(value) ? undefined : value
)
break break
case "email": case "email":
propertyValidator = string().email() propertyValidator = string().email()