object Constraint extends Serializable

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.")
}
Source
Validation.scala
Linear Supertypes
Serializable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Constraint
  2. Serializable
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. 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.

    name

    the constraint name

    args

    the constraint arguments, used to format the constraint name

    f

    the validation function

    returns

    a constraint

  2. 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.

    f

    the validation function

    returns

    a constraint