If expression example

Hello all,
I want to add a simple if condition that will check the value of a text field.
The value of the field might be Peeling or Eatable, if not, show a message on screen.
The condition will occuor by a trigger from a button on screen.
Like the following statement :
If field_name is blank or (field_name != ‘Peeling’ and field_name != ‘Eatable’) then
show message ‘…’
else
continue …
I know to split the two parts of the OR condition but do not know how to implement the second part.
Please help !!!

Thank you,
Amit

hello @Amit, welcome to the Tulip Community!!

just to confirm, do you want to show the message if any of these are in the input??

  • Peelable
  • Eatable
  • [blank]

if so, here’s the trigger you should add to the Button:

please note that the If must of of type Any.

let us know if I understood you correctly!!

Hi, Thank you for your quick answer,
This validation is a part of a long list of validations so I must do it on the negative answer, I will use for this the not equals to, this is ok, but how can I do it in a more short way using the expression editor ?

Thank you,
Amit

hello @Amit, no problem!!

have you tried using a regular expression in the expression editor?? something like this could work well: ^(Peeling|Eatable|\s*)$.

trigger:

let us know if you’re able to implement this!!

Hi, Wow it is working excellent !!!
Thank you very much for your help, can you explain the meaning of the ^ in the begining and the /S* and the $ sign in the end ?

Thank you,
Amit

no problem, happy to hear it!!

certainly, this guide: Assertions - JavaScript | MDN is a very useful reference for Regular Expressions.

  • ^ Matches the beginning of input.
  • $ Matches the end of input.
  • \s Matches a single white space character, including space, tab, form feed, line feed, and other Unicode spaces.

thanks again for asking your questions on Community!!