package accord

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

Value Members

  1. package dsl

  2. package java8

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

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


    To use these extensions, import this package as follows:

    import java.time.LocalDateTime
    import java.time.temporal.ChronoUnit
    import java.time.Duration
    case class Person( name: String, birthDate: LocalDateTime )
    // Import the Accord DSL and Java 8 extensions...
    import com.wix.accord.dsl._
    import com.wix.accord.java8._
    // LocalDateTime (and other temporals) are now supported
    implicit val personValidator = validator[ Person ] { p => is notEmpty
      p.birthDate is before( )


    Supported operations:

    // Simple equality/inequality
    val lastYear = 1L, ChronoUnit.YEARS )
    p.birthDate is equalTo( lastYear )
    p.birthDate is notEqualTo( lastYear )
    // Equality with tolerance (both variants are equivalent)
    val oneWeek = Duration.ofDays( 7L )
    p.birthDate is within( oneWeek ).of( lastYear )
    p.birthDate is within( 7L, ChronoUnit.DAYS ).of( lastYear )
    // Before/after
    val ageOfAdulthood = 18L, ChronoUnit.YEARS )
    p.birthDate is before( ageOfAdulthood )
    p.birthDate is after( ageOfAdulthood )
    // Arithmetic-style operations
    p.birthDate must be <= ageOfAdulthood
    p.birthDate is between( lastYear, oneWeek ) )
  3. def validate[T](x: T)(implicit validator: Validator[T]): Result

Inherited from AnyRef

Inherited from Any