com.wix

accord

package accord

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. class BaseValidator[T] extends Validator[T]

    Simplifies base validator implementation.

    Simplifies base validator implementation. Validators typically consist of an assertion/test and a resulting violation; this implementation takes two functions that describe this behavior and wires the appropriate logic. For example:

    class IsNull extends BaseValidator[ AnyRef ]( _ == null, _ -> "is not a null" )

    T

    The object type this validator operates on.

  2. class NullSafeValidator[T <: AnyRef] extends BaseValidator[T]

    An extension to com.wix.accord.BaseValidator that transparently fails on nulls.

    An extension to com.wix.accord.BaseValidator that transparently fails on nulls.

    T

    The object type this validator operates on.

  3. trait ViolationBuilder extends AnyRef

    Provides a convenience DSL for generating violations:

    Provides a convenience DSL for generating violations:

    - Rule violations can be created by specifying a value and constraint message as a tuple, for example: v -> "must not be empty" - Group violations can be created by extending the above to include children, as in: v -> "does not match any of the rules" -> Seq( v.firstName -> "first name must be empty", ... )

Value Members

  1. object ViolationBuilder extends ViolationBuilder

  2. package combinators

    Aggregates all implemented combinators for use by the DSL.

    Aggregates all implemented combinators for use by the DSL. Can, though not intended to, be used directly by end-user code.

  3. package dsl

    Provides a DSL for defining validation rules.

    Provides a DSL for defining validation rules. For example:

    import dsl._ // Import the validator DSL

    case class Person( firstName: String, lastName: String ) case class Classroom( teacher: Person, students: Seq[ Person ] )

    implicit val personValidator = validator[ Person ] { p => p.firstName is notEmpty p.lastName is notEmpty }

    implicit val classValidator = validator[ Classroom ] { c => c.teacher is valid // Implicitly relies on personValidator! c.students.each is valid c.students have size > 0 }

    These validators can later be executed via com.wix.accord.validate. A macro transforms each validation block into a chain of validation rules at compile-time, and annotates accesses to getters so that violation messages are automatically generated; for instance, the rule p.firstName is notEmpty will generate the violation message "firstName must not be empty" automatically.

  4. package transform

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

Inherited from AnyRef

Inherited from Any

Ungrouped