Last active
December 21, 2015 10:49
Revisions
-
erikrozendaal revised this gist
Aug 21, 2013 . No changes.There are no files selected for viewing
-
erikrozendaal revised this gist
Aug 21, 2013 . No changes.There are no files selected for viewing
-
erikrozendaal revised this gist
Aug 21, 2013 . No changes.There are no files selected for viewing
-
erikrozendaal created this gist
Aug 21, 2013 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ def notNull[A](a: A): Validation[String, A] = if (a != null) a.success else "may not be null".failure def size[A <% Traversable[_]](min: Int = 0, max: Int = Int.MaxValue)(a: A): Validation[String, A] = if (min to max contains a.size) a.success else s"size must be between $min and $max".failure // Composing notNull and size, like https://github.com/hibernate/hibernate-validator/blob/master/engine/src/main/java/org/hibernate/validator/constraints/NotEmpty.java#L48 def notEmpty[A <% Traversable[_]](a: A): Validation[String, A] = notNull(a) flatMap size(min = 1)