Last active
December 21, 2015 14:29
-
-
Save lanceon/6319947 to your computer and use it in GitHub Desktop.
Custom validation functions for mapper field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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