Skip to content

Instantly share code, notes, and snippets.

@O5ten
Created December 17, 2014 10:10
Show Gist options
  • Save O5ten/0dcb7580610320e34abd to your computer and use it in GitHub Desktop.
Save O5ten/0dcb7580610320e34abd to your computer and use it in GitHub Desktop.
validatable
validator: { v ->
try{
v = parseInt(v)
} catch (NumberFormatException e) {
field.background = Color.RED
field.revalidate()
return false
}
if (v >= 0 && v < MAX_VALUE) {
field.background = Color.WHITE
field.revalidate()
return true
} else {
field.background = Color.RED
field.revalidate()
return false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment