com.wix

accord

package accord

The entry-point to the Accord library.

Overview

An Accord validator is a typeclass, which adds data validation rules over an existing domain model. The api module deals with the usage site; details on how to define validators can be found in the core module.

To use a validator, simply import this package, make sure the validator is in scope and use the validate function:

scala> import com.wix.accord._
import com.wix.accord._

scala> import MyDomain._
import MyDomain._

scala> val person = Person( name = "Niklaus", surname = "Wirth", age = 81 )
person: MyDomain.Person = Person(Niklaus,Wirth,81)

scala> validate( person )
res0: com.wix.accord.Result = Success

See Result, Success and Failure for details of the result model.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. accord
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. case class Failure(violations: Set[Violation]) extends Result with Product with Serializable

    An object representing a failed validation result.

  2. case class GroupViolation(value: Any, constraint: String, children: Set[Violation], description: Description = Descriptions.Empty) extends Violation with Product with Serializable

    Describes the violation of a group of constraints.

  3. sealed trait Result extends AnyRef

    A base trait for validation results.

  4. case class RuleViolation(value: Any, constraint: String, description: Description = Descriptions.Empty) extends Violation with Product with Serializable

    Describes a simple validation rule violation (i.

  5. trait Validator[-T] extends (T) ⇒ Result

    A validator over some type T.

  6. sealed trait Violation extends AnyRef

    A base trait for all violation types.

Value Members

  1. object Descriptions

  2. object Implicits

    Provides alternative syntax for validation.

  3. object Success extends Result with Product with Serializable

    An object representing a successful validation result.

  4. object Validator

    A companion object mostly responsible for allowing null-safe validation of boxed Java primitive types.

  5. def validate[T](x: T)(implicit validator: Validator[T]): Result

    Validates the specified object and returns a validation com.wix.accord.Result.

    Validates the specified object and returns a validation com.wix.accord.Result. An implicit com.wix.accord.Validator must be in scope for this call to succeed.

    T

    The type of the object to validate.

    x

    The object to validate.

    validator

    A validator for objects of type T.

    returns

    A com.wix.accord.Result indicating success or failure of the validation.

Inherited from AnyRef

Inherited from Any

Ungrouped