% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/validate-horizon-geometry.R
\name{validate_horizon_geometry}
\alias{validate_horizon_geometry}
\title{Validate horizon depth geometry}
\usage{
validate_horizon_geometry(horizons)
}
\arguments{
\item{horizons}{A data frame with at least numeric \code{top_cm} and
\code{bottom_cm} columns (and optionally a \code{designation} column).}
}
\value{
A list with \code{valid} (logical; \code{TRUE} when there are no
  errors), \code{errors} and \code{warnings} (character vectors of
  human-readable English messages), and \code{details} -- a named list of
  the offending row indices (or values) per check, so a caller can compose
  its own (e.g. localised) messages.
}
\description{
A pure, side-effect-free check of a horizon table's depth geometry,
independent of any \code{\link{PedonRecord}}. The Pro app's Pedon builder
calls it to give immediate feedback while horizons are edited, and it is a
handy guard before constructing a profile from an untrusted CSV.
}
\details{
It reports two severities:
\describe{
  \item{errors (these make a sane classification impossible)}{a missing or
    non-numeric \code{top_cm}/\code{bottom_cm}; a negative depth; a horizon
    whose \code{top_cm >= bottom_cm} (inverted or zero thickness); two
    horizons whose depths overlap.}
  \item{warnings (allowed, but worth surfacing)}{the shallowest horizon not
    starting at the surface (0 cm); a gap between consecutive horizons;
    horizons entered out of increasing-depth order; a duplicated horizon
    designation.}
}

This complements \code{PedonRecord$validate()}, which additionally checks
chemistry (texture sums, pH, CEC vs bases, Munsell ranges); use that for a
built record and this for a raw table.
}
\examples{
h <- data.frame(top_cm = c(0, 20, 55), bottom_cm = c(20, 55, 90),
                designation = c("A", "AB", "Bt"))
validate_horizon_geometry(h)$valid          # TRUE

bad <- data.frame(top_cm = c(0, 40), bottom_cm = c(50, 30))  # overlap+inverted
validate_horizon_geometry(bad)$errors
}
