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 jap.fields._
FieldPath.Root
// res0: FieldPath = FieldPath(parts = List())
FieldPath(FieldPart.Path("request"), FieldPart.Index(2))
// res1: FieldPath = FieldPath(
// parts = List(Path(value = "request"), Index(value = 2))
// )
FieldPath.fromPaths("request", "name")
// res2: FieldPath = FieldPath(
// parts = List(Path(value = "request"), Path(value = "name"))
// )
FieldPath.fromPath("request")
// res3: FieldPath = FieldPath(parts = List(Path(value = "request")))
FieldPath.fromIndex(12)
// res4: FieldPath = FieldPath(parts = List(Index(value = 12)))
FieldPath.parse("request.name[1]")
// res5: FieldPath = FieldPath(
// parts = List(Path(value = "request"), Path(value = "name"), Index(value = 1))
// )
Operationsβ
val path = FieldPath.parse("a.b")
// path: FieldPath = FieldPath(
// parts = List(Path(value = "a"), Path(value = "b"))
// )
path.isRoot
// res6: Boolean = false
path.full
// res7: String = ".a.b"
path.name
// res8: String = "b"
path.named("c")
// res9: FieldPath = FieldPath(
// parts = List(Path(value = "a"), Path(value = "c"))
// )
path ++ FieldPath.fromPath("d")
// res10: FieldPath = FieldPath(
// parts = List(Path(value = "a"), Path(value = "b"), Path(value = "d"))
// )
path + "d"
// res11: FieldPath = FieldPath(
// parts = List(Path(value = "a"), Path(value = "b"), Path(value = "d"))
// )
path + FieldPart.Path("d")
// res12: FieldPath = FieldPath(
// parts = List(Path(value = "a"), Path(value = "b"), Path(value = "d"))
// )
path + 2
// res13: FieldPath = FieldPath(
// parts = List(Path(value = "a"), Path(value = "b"), Index(value = 2))
// )
path.down(2)
// res14: FieldPath = FieldPath(
// parts = List(Path(value = "a"), Path(value = "b"), Index(value = 2))
// )
path.down("d")
// res15: FieldPath = FieldPath(
// parts = List(Path(value = "a"), Path(value = "b"), Path(value = "d"))
// )
path.down(FieldPart.Path("d"))
// res16: FieldPath = FieldPath(
// parts = List(Path(value = "a"), Path(value = "b"), Path(value = "d"))
// )
Conversionsβ
import jap.fields.FieldPathConversions._
Field(FieldPath.fromPath("name"), ""): FieldPath
// res17: FieldPath = FieldPath(parts = List(Path(value = "name")))
"name": FieldPath
// res18: FieldPath = FieldPath(parts = List(Path(value = "name")))
2: FieldPath
// res19: FieldPath = FieldPath(parts = List(Index(value = 2)))
List("request", "name"): FieldPath
// res20: FieldPath = FieldPath(
// parts = List(Path(value = "request"), Path(value = "name"))
// )