-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 (number) Fix number input validation with variables
- Loading branch information
1 parent
3e02436
commit 7586eca
Showing
2 changed files
with
29 additions
and
7 deletions.
There are no files selected for viewing
31 changes: 25 additions & 6 deletions
31
packages/bot-engine/blocks/inputs/number/validateNumber.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,29 @@ | ||
import { isNotDefined } from '@typebot.io/lib' | ||
import { NumberInputBlock } from '@typebot.io/schemas' | ||
import { NumberInputBlock, Variable } from '@typebot.io/schemas' | ||
import { parseVariables } from '../../../variables/parseVariables' | ||
|
||
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)) | ||
{ | ||
options, | ||
variables, | ||
}: { | ||
options: NumberInputBlock['options'] | ||
variables: Variable[] | ||
} | ||
) => { | ||
const min = | ||
options?.min && typeof options.min === 'string' | ||
? Number(parseVariables(variables)(options.min)) | ||
: undefined | ||
const max = | ||
options?.min && typeof options.min === 'string' | ||
? Number(parseVariables(variables)(options.min)) | ||
: undefined | ||
|
||
return ( | ||
inputValue !== '' && | ||
(isNotDefined(min) || Number(inputValue) >= min) && | ||
(isNotDefined(max) || Number(inputValue) <= max) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7586eca
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
landing-page-v2 – ./apps/landing-page
landing-page-v2-typebot-io.vercel.app
www.get-typebot.com
landing-page-v2-git-main-typebot-io.vercel.app
get-typebot.com
www.typebot.io
home.typebot.io
7586eca
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
docs – ./apps/docs
docs-typebot-io.vercel.app
docs.typebot.io
docs-git-main-typebot-io.vercel.app
7586eca
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
viewer-v2 – ./apps/viewer
vhpage.cr8.ai
vitamyway.com
whatchat.site
www.wiccom.it
acessovip.shop
adsgrow.com.br
am.nigerias.io
an.nigerias.io
app.yvon.earth
ar.nigerias.io
bot.enreso.org
bot.wphelpchat.com
bots.robomotion.io
brandingmkt.com.br
bt.chatgptlabs.org
cadu.uninta.edu.br
chat.daftarjer.com
chat.foxbot.online
chat.hand-made.one
chat.tuanpakya.com
chat.webisharp.com
chatbotforthat.com
descobrindotudo.me
dicanatural.online
digitalhelp.com.au
draraquelnutri.com
drcarlosyoshi.site
goalsettingbot.com
golpenuncamais.com
leads.gecoelho.com
noticiasnet.online
novoappespiao.site
omarcodosanjos.com
pant.maxbot.com.br
pantherview.cr8.ai
positivobra.com.br
rollingball.cr8.ai
ruletaiapro.online
seletiva-bbb24.com
speciallife.com.br
sub.yolozeeeer.com
survey.digienge.io
tribe.ezbooking.ai
w.onewebcenter.com
web.lordromulo.com
zap.techadviser.in
zero-pendencia.com
ai.convobuilder.com
ai.digitaldaftar.in
al.onewebcenter.com
app.danielnalex.com
ask.realversity.org
blazecontrol.com.br
bot.boston-voip.com
bot.cabinpromos.com
bot.carnaval.studio
bot.digitalbled.com
bot.dsignagency.com
bot.enthrallart.com
viewer-v2-typebot-io.vercel.app
register.thailandmicespecialist.com
mdb.assessoria.desideri.progenbr.com
mdb.assessoria.fernanda.progenbr.com
mdb.assessoria.jbatista.progenbr.com
mdb.assessoria.mauricio.progenbr.com
mdb.evento.autocadastro.progenbr.com
form.shopmercedesbenzsouthorlando.com
mdb.evento.equipeinterna.progenbr.com
bot.studiotecnicoimmobiliaremerelli.it
mdb.assessoria.boaventura.progenbr.com
mdb.assessoria.jtrebesqui.progenbr.com
pesquisa.escolamodacomproposito.com.br
anamnese.clinicaramosodontologia.com.br
gabinete.baleia.formulario.progenbr.com
mdb.assessoria.carreirinha.progenbr.com
chrome-os-inquiry-system.itschromeos.com
mdb.assessoria.paulomarques.progenbr.com
viewer-v2-git-main-typebot-io.vercel.app
main-menu-for-itschromeos.itschromeos.com
mdb.assessoria.qrcode.ademir.progenbr.com
mdb.assessoria.qrcode.arthur.progenbr.com
mdb.assessoria.qrcode.danilo.progenbr.com
mdb.assessoria.qrcode.marcao.progenbr.com
mdb.assessoria.qrcode.marcio.progenbr.com
mdb.assessoria.qrcode.aloisio.progenbr.com
mdb.assessoria.qrcode.girotto.progenbr.com
mdb.assessoria.qrcode.marinho.progenbr.com
mdb.assessoria.qrcode.rodrigo.progenbr.com
mdb.assessoria.carlosalexandre.progenbr.com
mdb.assessoria.qrcode.desideri.progenbr.com
mdb.assessoria.qrcode.fernanda.progenbr.com
mdb.assessoria.qrcode.jbatista.progenbr.com
mdb.assessoria.qrcode.mauricio.progenbr.com
mdb.assessoria.fernanda.regional.progenbr.com
mdb.assessoria.qrcode.boaventura.progenbr.com
mdb.assessoria.qrcode.jtrebesqui.progenbr.com
mdb.assessoria.qrcode.carreirinha.progenbr.com
mdb.assessoria.qrcode.paulomarques.progenbr.com
mdb.assessoria.qrcode.carlosalexandre.progenbr.com
mdb.assessoria.qrcode.fernanda.regional.progenbr.com
7586eca
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
builder-v2 – ./apps/builder
app.typebot.io
builder-v2-git-main-typebot-io.vercel.app
builder-v2-typebot-io.vercel.app