Back to Blog

Check and verify user input

For several cases it you might want to check the user input before proceed. A case that we encounter often is a check for the order number. A number verification or check can be created in before proceeding the process. To create a verification step you’ll need data to verify and some verification rules.

Data to verify

First, we’ll need some data that we can verify. You can use entities to extract parameters or you can use the complete user query. For more information about parameters please consult Params docs.

Verification rules

To verify your data you’ll need a couple of rules that you’ll implement. When have your rules in place, you can translate them to Java script code within actions or cloud code. In this example we got the following rules for the parameter

  1. The parameter is between 7 and 12 characters
  2. The first 4 characters consist of “2019” or “2020”
  3. If correct, trigger the event “filenumber correct”
  4. If incorrect, trigger the event “filenumber incorrect”

Make sure to create an event with the corresponding names otherwise you’ll be stuck within the action code.

  const filenumber = // use input query or param here
  const years = [`2019`, `2020`]
  if(filenumber.length > 7 && filenumber.length  < 12  && 
    trigger('filenumber correct');
   else {
    trigger('filenumber incorrect');
Start for freeContact us