Compose two Rules
Compose two Rules
val r1: Rule[JsValue, String] = // implementation val r2: Rule[String, Date] = // implementation val r = r1 .andThen(r2)
a prefix for the errors path if the result is a Invalid
the second Rule to apply
The combination of the two Rules
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)
an alternative Rule
a Rule
This methods allows you to modify the Path of errors (if the result is a Invalid) when aplying the Rule
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")
(Since version 2.0) use andThen instead.
(Since version 2.0) use andThen instead.
(Since version 2.0) use andThen instead.
(Since version 2.0) fmap is deprecated, use map instead