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

Value Members

  1. package dsl

  2. package joda

    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

Inherited from AnyRef

Inherited from Any

Ungrouped