Trait/Object

jto.validation

Rule

Related Docs: object Rule | package validation

Permalink

trait Rule[I, O] extends RuleLike[I, O]

Linear Supertypes
RuleLike[I, O], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Rule
  2. RuleLike
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def validate(data: I): VA[O]

    Permalink

    Apply the Rule to data

    Apply the Rule to data

    data

    The data to validate

    returns

    The Result of validating the data

    Definition Classes
    RuleLike

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def andThen[P](m: Mapping[ValidationError, O, P]): Rule[I, P]

    Permalink
  5. def andThen[P](sub: ⇒ RuleLike[O, P]): Rule[I, P]

    Permalink
  6. def andThen[P](path: Path)(sub: ⇒ RuleLike[O, P]): Rule[I, P]

    Permalink

    Compose two Rules

    Compose two Rules

    val r1: Rule[JsValue, String] = // implementation
    val r2: Rule[String, Date] = // implementation
    val r = r1 .andThen(r2)
    path

    a prefix for the errors path if the result is a Invalid

    sub

    the second Rule to apply

    returns

    The combination of the two Rules

  7. def ap[A](mf: Rule[I, (O) ⇒ A]): Rule[I, A]

    Permalink
  8. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  9. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  10. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  11. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  12. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  13. def flatMap[B](f: (O) ⇒ Rule[I, B]): Rule[I, B]

    Permalink
  14. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  15. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  16. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  17. def map[B](f: (O) ⇒ B): Rule[I, B]

    Permalink
  18. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  19. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  20. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  21. def orElse[OO >: O](t: ⇒ RuleLike[I, OO]): Rule[I, OO]

    Permalink

    Create a new Rule that try this Rule, and apply t if it fails

    Create a new Rule that try this Rule, and apply t if it fails

    val rb: Rule[JsValue, A] = From[JsValue]{ __ =>
      ((__ \ "name").read[String] ~ (__ \ "foo").read[Int])(B.apply)
    }
    
    val rc: Rule[JsValue, A] = From[JsValue]{ __ =>
      ((__ \ "name").read[String] ~ (__ \ "bar").read[Int])(C.apply)
    }
    val rule = rb orElse rc orElse Rule(_ => typeInvalid)
    t

    an alternative Rule

    returns

    a Rule

  22. def repath(f: (Path) ⇒ Path): Rule[I, O]

    Permalink

    This methods allows you to modify the Path of errors (if the result is a Invalid) when aplying the Rule

  23. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  24. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  25. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  28. def |+|[OO <: O](r2: RuleLike[I, OO]): Rule[I, O]

    Permalink

    Create a new Rule the validate this Rule and r2 simultaneously If this and r2 both fail, all the error are returned

    Create a new Rule the validate this Rule and r2 simultaneously If this and r2 both fail, all the error are returned

    val valid = Json.obj(
       "firstname" -> "Julien",
       "lastname" -> "Tournay")
    val composed = notEmpty |+| minLength(3)
    (Path \ "firstname").read(composed).validate(valid) // Valid("Julien")

Deprecated Value Members

  1. def compose[P](m: Mapping[ValidationError, O, P]): Rule[I, P]

    Permalink
    Annotations
    @deprecated
    Deprecated

    (Since version 2.0) use andThen instead.

  2. def compose[P](sub: ⇒ RuleLike[O, P]): Rule[I, P]

    Permalink
    Annotations
    @deprecated
    Deprecated

    (Since version 2.0) use andThen instead.

  3. def compose[P](path: Path)(sub: ⇒ RuleLike[O, P]): Rule[I, P]

    Permalink
    Annotations
    @deprecated
    Deprecated

    (Since version 2.0) use andThen instead.

  4. def fmap[B](f: (O) ⇒ B): Rule[I, B]

    Permalink
    Annotations
    @deprecated
    Deprecated

    (Since version 2.0) fmap is deprecated, use map instead

Inherited from RuleLike[I, O]

Inherited from AnyRef

Inherited from Any

Ungrouped