Constraint

play.api.data.validation.Constraint
See theConstraint companion class
object Constraint

This object provides helpers for creating Constraint values.

For example:

 val negative = Constraint[Int] {
   case i if i < 0 => Valid
   case _ => Invalid("Must be a negative number.")
 }

Attributes

Companion
class
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Constraint.type

Members list

Value members

Concrete methods

def apply[T](f: T => ValidationResult): Constraint[T]

Creates a new anonymous constraint from a validation function.

Creates a new anonymous constraint from a validation function.

Value parameters

f

the validation function

Attributes

Returns

a constraint

def apply[T](name: String, args: Any*)(f: T => ValidationResult): Constraint[T]

Creates a new named constraint from a validation function.

Creates a new named constraint from a validation function.

Value parameters

args

the constraint arguments, used to format the constraint name

f

the validation function

name

the constraint name

Attributes

Returns

a constraint