🚸 (variables) Allow null values in variable list
This commit is contained in:
@@ -48,7 +48,7 @@ export const safeStringify = (val: unknown): string | null => {
|
||||
|
||||
export const parseCorrectValueType = (
|
||||
value: Variable['value']
|
||||
): string | string[] | boolean | number | null | undefined => {
|
||||
): string | (string | null)[] | boolean | number | null | undefined => {
|
||||
if (value === null) return null
|
||||
if (value === undefined) return undefined
|
||||
if (Array.isArray(value)) return value
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
} from './blocks'
|
||||
import { publicTypebotSchema } from './publicTypebot'
|
||||
import { logSchema, resultSchema } from './result'
|
||||
import { typebotSchema } from './typebot'
|
||||
import { listVariableValue, typebotSchema } from './typebot'
|
||||
import {
|
||||
textBubbleContentSchema,
|
||||
imageBubbleContentSchema,
|
||||
@@ -123,7 +123,7 @@ const scriptToExecuteSchema = z.object({
|
||||
.string()
|
||||
.or(z.number())
|
||||
.or(z.boolean())
|
||||
.or(z.array(z.string()))
|
||||
.or(listVariableValue)
|
||||
.nullish(),
|
||||
})
|
||||
),
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const listVariableValue = z.array(z.string().nullable())
|
||||
|
||||
export const variableSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
value: z.string().or(z.array(z.string())).nullish(),
|
||||
value: z.string().or(listVariableValue).nullish(),
|
||||
})
|
||||
|
||||
/**
|
||||
@@ -12,7 +14,7 @@ export const variableSchema = z.object({
|
||||
export const variableWithValueSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
value: z.string().or(z.array(z.string())),
|
||||
value: z.string().or(listVariableValue),
|
||||
})
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user