Smartapp preference validation

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.