2
0

🐛 (numberInput) Fix input clearing out on dot or comma press

This commit is contained in:
Baptiste Arnaud
2023-10-25 17:37:45 +02:00
parent c2a08c482e
commit 4b248d554f
8 changed files with 69 additions and 15 deletions

View File

@@ -0,0 +1 @@
export const parseNumber = (value: string) => Number(value).toString()

View File

@@ -1 +1,10 @@
export const validateNumber = (inputValue: string) => !isNaN(Number(inputValue))
import { isNotDefined } from '@typebot.io/lib'
import { NumberInputBlock } from '@typebot.io/schemas'
export const validateNumber = (
inputValue: string,
options: NumberInputBlock['options']
) =>
inputValue !== '' &&
(isNotDefined(options?.min) || Number(inputValue) >= Number(options.min)) &&
(isNotDefined(options?.max) || Number(inputValue) <= Number(options.max))