Package

com.wix

accord

Permalink

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
Visibility
  1. Public
  2. All

Value Members

  1. package dsl

    Permalink
  2. package joda

    Permalink

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

    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 )
  3. def validate[T](x: T)(implicit validator: Validator[T]): Result

    Permalink

Inherited from AnyRef

Inherited from Any

Ungrouped