Skip to main content
1-Visitor
June 26, 2014
Question

Validator

  • June 26, 2014
  • 1 reply
  • 3275 views

Hello,

I am trying to use a validator widget in my mashup. I have the following code but it doesn't seem to work. Not sure how to write the expression in the validator. I have a parameter input to the widget called Expanded.

if Expanded = False then Output = True else if Expanded = True then Output = False

Thank you,

Mike

    1 reply

    5-Regular Member
    June 26, 2014

    Hi Mike,

    The Expression widget expects JavaScript just as our

    Services

    do. You have a couple of options when writing this particular expression – given the small size of the Expression text box, I recommend using the most concise and least error-prone expression possible. Keep in mind, '=' is the assignment operator and '==' is a relational operator which tests for equality. Furthermore, the boolean keywords 'true' and 'false' should be lowercased and there is no 'then' keyword in JavaScript.


    Since Expanded is a boolean value a simple if-else will suffice. You can take advantage of the logical negation operator along with the conditional operator (?) to get a nice short expression:


    !Expanded ? true : false;


    or, if you prefer something closer to what you had:


    if (Expanded == false) { result = true; } else { result = false; }


    Thanks,

    Adam



    15-Moonstone
    October 10, 2017

    Hello Adam,

    Just saw this post and was curious to ask weather i can validate the expression below using Validator widget.


    (((1-2)*5.797*(((((mA1-4000000)/1000000)+1)-((mA2-4000000)/16000000))^3))+(61.196*(((((mA1-4000000)/1000000)+1)-((mA2-4000000)/16000000))^2))-(218.96*((((mA1-4000000)/1000000)+1)-((mA2-

    IF(1000 100;10;20)

    )/16000000))))+291.5


    1. mA1 and mA2 are replaced with the values later.

    2. And also i have used if condition between the expression.


    If i cannot achieve the same using validator widget, what is the best possible solution to my problem.


    Thanks

    Sunay