There is an `oae.api.util.validation` helper function that you should be able to simplify this. See the `accountpreferences` widget for an example of usage