validation.FieldPath.scala Maven / Gradle / Ivy
package jap
package validation
case class FieldPath(value: List[String]) extends AnyVal {
def isRoot = value.isEmpty
def full: String = if (isRoot) "root" else value.mkString(".")
def name: String = value.lastOption.getOrElse("root")
def named(name: String): FieldPath = FieldPath(value.dropRight(1) :+ name)
def ++(path: FieldPath): FieldPath = FieldPath(value ++ path.value)
def +(path: String): FieldPath = FieldPath(value :+ path)
override def toString: String = full
}
object FieldPath {
val root = FieldPath()
def apply(value: String*): FieldPath = FieldPath(value.toList)
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy