✨ Introducing The Forge (#1072)
The Forge allows anyone to easily create their own Typebot Block. Closes #380
This commit is contained in:
12
packages/variables/parseVariableNumber.ts
Normal file
12
packages/variables/parseVariableNumber.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { Variable } from '@typebot.io/schemas'
|
||||
import { parseGuessedValueType } from './parseGuessedValueType'
|
||||
import { parseVariables } from './parseVariables'
|
||||
|
||||
export const parseVariableNumber =
|
||||
(variables: Variable[]) =>
|
||||
(input: number | `{{${string}}}` | undefined): number | undefined => {
|
||||
if (typeof input === 'number' || input === undefined) return input
|
||||
const parsedInput = parseGuessedValueType(parseVariables(variables)(input))
|
||||
if (typeof parsedInput !== 'number') return undefined
|
||||
return parsedInput
|
||||
}
|
Reference in New Issue
Block a user