Skip to content

Instantly share code, notes, and snippets.

@lanceon
Last active December 21, 2015 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lanceon/6319947 to your computer and use it in GitHub Desktop.
Save lanceon/6319947 to your computer and use it in GitHub Desktop.
Custom validation functions for mapper field
class Test extends LongKeyedMapper[Test] ...
{
...
object data MappedString(this, 32) {
def validateFormat(s: String) =
if (s.matches("[a-z0-9_]+")) Nil
else List(FieldError(this, "Format is not valid!"))
override def validations = validateFormat _ :: Nil
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment