Smartapp preference validation

(Gary D) #1

Is there any mechanism (I don’t see one) to do preference validation in the preferences pages themselves?

For example (and this is just an example) I might want two “number” inputs, but the second number must be greater than the first. How can I enforce this on the preferences page?

preferences {
    section("section title") {
        input "val1", "number", title: "first value"

        input "val2", "number", title: "second value - must be greater than the first value"
    // how can I not accept the preferences as valid if val2 < val1?

(Eric R) #2

There was some conversation about this a while ago: Is Input Validation Possible?.

The solution there is not very elegant, but it works. You could apply it to this situation.