Input Validation


(Hw) #1

Hi,

Anyone knows if there are any way to feed back to the user that the input value is invalid?

For example, I am trying to write an app that notify the user when a device battery level drops below a certain percentage and would like to restrict his/her inputs to 0 to 99.
Tried throwing exception, but instead of getting a message displayed to the user, I got an “Error: Connection failed.”.

section “Battery Level” {
input “battLevel”, “number”, title:“Battery level”
}

Any way to specify a range to the above? e.g. input “battLevel”, “number”, title: “Battery level”, max:99


(Todd Wackford) #2

Not until there is multipage or forked preference functionality. I hear it is coming soon.


(Chrisb) #3

I suppose you could run an if/then on the value and send a push notification if the value was outside of the given parameters. Obviously that wouldn’t prevent the user from installing and using the app with an unacceptable value, but it would at least alert him/her that the app isn’t going to work as desired.