FieldPath
Stores Field path, that at the end of the day is used to know where some ValidationError was raised.
Various ways to create and transform FieldPath is described in Syntax section
Syntaxβ
Createβ
import fields._
case class Form(name: String)
case class Request(form: Form)
FieldPath.Root
// res0: FieldPath = .
FieldPath(FieldPart.Path("request"), FieldPart.Index(2))
// res1: FieldPath = .request[2]
FieldPath.fromPaths("request", "name")
// res2: FieldPath = .request.name
FieldPath.fromPath("request")
// res3: FieldPath = .request
FieldPath.fromIndex(12)
// res4: FieldPath = [12]
FieldPath.parse("request.name[1]")
// res5: FieldPath = .request.name[1]
val request = Request(Form("Ann"))
// request: Request = Request(Form("Ann"))
FieldPath.sub(request.form.name)
// res6: FieldPath = .form.name
FieldPath.from(request.form.name)
// res7: FieldPath = .request.form.name
FieldPath.from((request: Request) => request.form.name)
// res8: FieldPath = .request.form.name
FieldPath.sub((request: Request) => request.form.name)
// res9: FieldPath = .form.name
Operationsβ
val path = FieldPath.parse("a.b")
// path: FieldPath = .a.b
path.isRoot
// res10: Boolean = false
path.full
// res11: String = ".a.b"
path.name
// res12: String = "b"
path.named("c")
// res13: FieldPath = .a.c
path ++ FieldPath.fromPath("d")
// res14: FieldPath = .a.b.d
path + "d"
// res15: FieldPath = .a.b.d
path + FieldPart.Path("d")
// res16: FieldPath = .a.b.d
path + 2
// res17: FieldPath = .a.b[2]
path.down(2)
// res18: FieldPath = .a.b[2]
path.downKey("key")
// res19: FieldPath = .a.b[key]
path.down("d")
// res20: FieldPath = .a.b.d
path.down(FieldPart.Path("d"))
// res21: FieldPath = .a.b.d