Trait/Object

play.api.data.mapping

Rule

Related Docs: object Rule | package mapping

Permalink

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

A Rule is

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. final def asInstanceOf[T0]: T0

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

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. def compose[P](m: Mapping[ValidationError, O, P]): Rule[I, P]

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

    Permalink
  8. def compose[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.compose(r2)
    path

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

    sub

    the second Rule to apply

    returns

    The combination of the two Rules

  9. final def eq(arg0: AnyRef): Boolean

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

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

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

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

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

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

    Permalink
    Definition Classes
    Any
  16. final def ne(arg0: AnyRef): Boolean

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

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

    Permalink
    Definition Classes
    AnyRef
  19. 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(_ => typeFailure)
    t

    an alternative Rule

    returns

    a Rule

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

    Permalink

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

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

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

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

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. 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) // Success("Julien")

Inherited from RuleLike[I, O]

Inherited from AnyRef

Inherited from Any

Ungrouped