% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/write_utils.R
\name{.prepare_write_data}
\alias{.prepare_write_data}
\title{Truncate overflow values and warn about bool NA values before writing}
\usage{
.prepare_write_data(x, metadata)
}
\arguments{
\item{x}{The R array to be written.}

\item{metadata}{Array metadata list as returned by \code{\link[=.read_array_metadata]{.read_array_metadata()}}.}
}
\value{
\code{x}, possibly with overflow values clamped.
}
\description{
Applies the two pre-write data checks that are needed identically in both
\code{\link[=write_zarr_array]{write_zarr_array()}} and \code{\link[=update_zarr_array]{update_zarr_array()}}:
}
\details{
\enumerate{
\item If the target type is narrower than R's native representation (e.g.
\code{int8}, \code{int16}, \code{float32}), clamp out-of-range values via
\code{.truncate_overflow()}.
\item If the target type is \code{bool}, warn when \code{x} contains \code{NA} values (which
the Zarr bool type cannot represent).
}
}
\keyword{internal}
