com.wix

accord

package accord

The entry-point to the Accord library. To execute a validator, simply import it into the local scope, import this package and execute validate( objectUnderValidation ).

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.

    An object representing a failed validation result.

    violations

    The violations that caused the validation to fail.

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

    Describes the violation of a group of constraints.

    Describes the violation of a group of constraints. For example, the com.wix.accord.combinators.Or combinator produces a group violation when all predicates fail.

    value

    The value of the object which failed the validation rule.

    constraint

    A textual description of the constraint being violated (for example, "must not be empty").

    description

    The textual description of the object under validation.

    children

    The set of violations contained within the group.

  3. sealed trait Result extends AnyRef

    A base trait for validation results.

    A base trait for validation results.

    See also

    com.wix.accord.Success, com.wix.accord.Failure

  4. case class RuleViolation(value: Any, constraint: String, description: Option[String]) extends Violation with Product with Serializable

    Describes the violation of a validation rule or constraint.

    Describes the violation of a validation rule or constraint.

    value

    The value of the object which failed the validation rule.

    constraint

    A textual description of the constraint being violated (for example, "must not be empty").

    description

    The textual description of the object under validation.

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

    A validator is a function T => Result, where T is the type of the object under validation and Result is an instance of com.wix.accord.Result.

    A validator is a function T => Result, where T is the type of the object under validation and Result is an instance of com.wix.accord.Result.

    Implementation note: While theoretically a validator can be defined as a type alias, in practice this doesn't allow to specify an error message when it's implicitly missing at the call site (see scala.annotation.implicitNotFound).

    T

    The object type this validator operates on.

    Annotations
    @implicitNotFound( ... )
  6. sealed trait Violation extends AnyRef

    A base trait for all violation types.

Value Members

  1. object Implicits

    Provides alternative syntax for validation.

    Provides alternative syntax for validation. Instead of having to explicitly call com.wix.accord.validate, an object can be validated by calling instanceUnderTest.validate. This is strictly an aesthetic preference, there are no differences in implementation or execution.

  2. object Success extends Result with Product with Serializable

    An object representing a successful validation result.

  3. object Validator

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