Package

com.wix.accord

joda

Permalink

package joda

Adds support for ReadableInstants (and subclasses) to the Accord DSL.

Usage

To use these extensions, import this package as follows:

import org.joda.time.DateTime
import org.joda.time.Duration

case class Person( name: String, birthDate: DateTime )

// Import the Accord DSL and JODA extensions...
import com.wix.accord.dsl._
import com.wix.accord.joda._

// DateTime (and other instant types) are now supported
implicit val personValidator = validator[ Person ] { p =>
  p.name is notEmpty
  p.birthDate is before( DateTime.now )
}

Combinators

Supported operations:

// Simple equality/inequality
val lastYear = DateTime.now.minus( Duration.standardDays( 365L ) )
p.birthDate is equalTo( lastYear )
p.birthDate is notEqualTo( lastYear )

// Equality with tolerance
p.birthDate is within( Duration.standardDays( 7L ) ).of( lastYear )

// Before/after
val ageOfAdulthood = DateTime.now.minus( Duration.standardDays( 18 * 365L ) )
p.birthDate is before( ageOfAdulthood )
p.birthDate is after( ageOfAdulthood )
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. joda
  2. ReadableInstantOps
  3. ReadableInstantCombinators
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. class After[T <: ReadableInstant] extends NullSafeValidator[T]

    Permalink

    A validator that succeeds only for values that come strictly after before the specified bound.

    A validator that succeeds only for values that come strictly after before the specified bound.

    Definition Classes
    ReadableInstantCombinators
  2. class Before[T <: ReadableInstant] extends NullSafeValidator[T]

    Permalink

    A validator that succeeds only for values that come strictly before the specified bound.

    A validator that succeeds only for values that come strictly before the specified bound.

    Definition Classes
    ReadableInstantCombinators
  3. implicit class ExtendAccordDSL extends AnyRef

    Permalink

    Extends the Accord DSL with additional within operations over instants.

    Extends the Accord DSL with additional within operations over instants.

    Definition Classes
    ReadableInstantOps
  4. trait ReadableInstantCombinators extends AnyRef

    Permalink

    Combinators that operate specifically on instants (and subclasses thereof).

  5. trait ReadableInstantOps extends AnyRef

    Permalink

    Provides a DSL for validating ReadableInstants (and subclasses thereof).

  6. class Within[T <: ReadableInstant] extends NullSafeValidator[T]

    Permalink

    A validator that succeeds only for values that are within (i.e.

    A validator that succeeds only for values that are within (i.e. before or after) a period of the specified temporal (for example, "within a month of this person's birth date").

    This is essentially equivalent to (value >= of - duration) && (value <= of + duration).

    Definition Classes
    ReadableInstantCombinators
  7. class WithinBuilder[T <: ReadableInstant] extends AnyRef

    Permalink

    A builder to support the within DSL extensions.

    A builder to support the within DSL extensions.

    Definition Classes
    ReadableInstantOps

Value Members

  1. def after[T <: ReadableInstant](right: T): After[T]

    Permalink

    Generates a validator that succeeds only if the provided value comes strictly after the specified bound.

    Generates a validator that succeeds only if the provided value comes strictly after the specified bound.

    Definition Classes
    ReadableInstantOps
  2. def before[T <: ReadableInstant](right: T): Before[T]

    Permalink

    Generates a validator that succeeds only if the provided value comes strictly before the specified bound.

    Generates a validator that succeeds only if the provided value comes strictly before the specified bound.

    Definition Classes
    ReadableInstantOps

Inherited from ReadableInstantOps

Inherited from AnyRef

Inherited from Any

Ungrouped