JsValue
has two methods
def validate[A](implicit rds: Reads[A]): JsResult[A]
- Tries to convert the node into a JsResult[T] (Success or Error).
def validateOpt[A](implicit rds: Reads[A]): JsResult[Option[A]]
- I suppose it also does the same thing.
In which situation would validateOpt
be used? In my opinion, if JsResult
fails then I'll get the error in JsError
. So what is the point of having an additional layer of Option
in JsSuccess
as JsSuccess
will always contain value after successful conversion of JsValue
into the type A
?