question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Need Multiple condition check

See original GitHub issue

Issue type

"switch_1"
"switch_2",
    {
      "key": "email",
      "condition": "model.switch_1",
      "required": true
    }

Current behavior

    {
      "key": "email",
      "condition": "model.switch_1",
      "required": true
    }

Expected behavior

    {
      "key": "email",
      "condition": "model.switch_1 && model.switch_2",
      "required": true
    }

How can I use multiple condiiton?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
lohruncommented, Feb 11, 2022

For a very similar need, I encountered the same issue. The JSON parser does not like the inline javascript function as suggested in @ramm24 first answer. However, using the following object syntax, it is possible to embed the function’s body into a string and have the form engine correctly interpret the information.

   {
      "key": "email",
      "condition": {
         "functionBody": "return model['switch_1'] && model['switch_2'];"
      },
      "required": true
   }
0reactions
ramm24commented, Sep 13, 2018

@stretau you will need to recursively look into your json and add a reference to a function.

Your Json could be have something like this.

"condition":  "functionName"

then just look for it using a recursive function and replace the “functionName” with the actual function reference.

function functionName(model)  {
    return model.requestAction === 'Add';
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Check multiple conditions in if statement - Python
Here we'll study how can we check multiple conditions in a single if statement. This can be done by using 'and' or 'or'...
Read more >
How to Check Multiple Conditions in a Python if statement
Conditional statements are fundamental to any programming language. Here, we show you how to implement them to check multiple conditions in ...
Read more >
Excel IF function with multiple conditions - Ablebits
Nested IF statement to check multiple logical tests ... If you want to evaluate multiple logical tests within a single formula, then you...
Read more >
Efficiently Check Multiple Conditions - java - Stack Overflow
I've got a situation in which I need to check multiple conditions, where every combination has a different outcome. In my specific condition...
Read more >
How to check multiple conditions - Hacking with Swift
To finish up with checking multiple conditions, let's try a more complex example that combines if , else if , else , and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found