1
0
Fork 0
mirror of synced 2024-06-29 11:31:06 +12:00

Make NaN undefined

This commit is contained in:
Mel O'Hagan 2022-10-24 10:18:51 +01:00
parent 30bf3dde6c
commit 0f729dee1b
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 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)

View file

@ -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()