% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils-validation.R
\name{validate_pnadc}
\alias{validate_pnadc}
\title{Validate PNADC Input Data}
\usage{
validate_pnadc(data, check_weights = FALSE, stop_on_error = TRUE)
}
\arguments{
\item{data}{A data.frame or data.table with PNADC microdata}

\item{check_weights}{Logical. If TRUE, also check for weight-related variables.}

\item{stop_on_error}{Logical. If TRUE, stops with an error. If FALSE, returns
a validation report list.}
}
\value{
If \code{stop_on_error = TRUE}, returns invisibly if valid or stops with error.
If \code{stop_on_error = FALSE}, returns a list with:
\itemize{
\item \code{valid}: Logical indicating if data passed all validations
\item \code{issues}: Named list of validation issues found (empty if none)
\item \code{n_rows}: Number of rows in input data
\item \code{n_cols}: Number of columns in input data
\item \code{join_keys_available}: Character vector of available join key columns
}
}
\description{
Checks that input data has required columns for the specified processing.
}
\details{
The function performs the following validations:
\itemize{
\item Checks for required columns for reference period identification:
\code{Ano}, \code{Trimestre}, \code{UPA}, \code{V1008}, \code{V1014},
\code{V2008}, \code{V20081}, \code{V20082}, \code{V2009}
\item Validates year range (2012-2100 for PNADC coverage)
\item Validates quarter values (must be 1-4)
\item Validates birth day values (must be 1-31 or 99 for unknown)
\item Validates birth month values (must be 1-12 or 99 for unknown)
\item Warns about unusual ages (outside 0-130 range)
\item If \code{check_weights = TRUE}, also validates weight-related columns:
\code{V1028}, \code{UF}, \code{posest}, \code{posest_sxi}
}
}
\examples{
# Minimal valid data (all 9 required columns)
sample_data <- data.frame(
  Ano = 2023L, Trimestre = 1L, UPA = 110000001L,
  V1008 = 1L, V1014 = 1L,
  V2008 = 15L, V20081 = 3L, V20082 = 1990L, V2009 = 33L
)
validate_pnadc(sample_data)

# Data with missing columns returns issues (non-stop mode)
incomplete_data <- data.frame(Ano = 2023L, Trimestre = 1L)
result <- validate_pnadc(incomplete_data, stop_on_error = FALSE)
result$valid    # FALSE
result$issues   # lists missing columns

}
\seealso{
\code{\link{pnadc_identify_periods}} which calls this function
internally to validate input data.
}
