play.api.data.validation

Contains the validation API used by Form.

For example, to define a custom constraint:

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

Attributes

Members list

Type members

Classlikes

case class Constraint[-T](name: Option[String], args: Seq[Any])(f: T => ValidationResult)

A form constraint.

A form constraint.

Type parameters

T

type of values handled by this constraint

Value parameters

args

the message arguments, to format the constraint name

f

the validation function

name

the constraint name, to be displayed to final user

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Constraint

This object provides helpers for creating Constraint values.

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
Supertypes
class Object
trait Matchable
class Any
Self type
Constraint.type
object Constraints extends Constraints

Defines a set of built-in constraints.

Defines a set of built-in constraints.

Attributes

Companion
trait
Supertypes
trait Constraints
class Object
trait Matchable
class Any
Self type
trait Constraints

Defines a set of built-in constraints.

Defines a set of built-in constraints.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Constraints.type
case class Invalid(errors: Seq[ValidationError]) extends ValidationResult

Validation was a failure.

Validation was a failure.

Value parameters

errors

the resulting errors

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Invalid

This object provides helper methods to construct Invalid values.

This object provides helper methods to construct Invalid values.

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Invalid.type

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
case object Valid extends ValidationResult

Validation was a success.

Validation was a success.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Self type
Valid.type
case class ValidationError(messages: Seq[String], args: Any*)

A validation error.

A validation error.

Value parameters

args

the error message arguments

messages

the error message, if more then one message is passed it will use the last one

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
sealed trait ValidationResult

A validation result.

A validation result.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Invalid
object Valid.type