% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/arg_character.R
\name{arg_character}
\alias{arg_character}
\alias{arg_string}
\alias{arg_factor}
\title{Check Character Argument}
\usage{
arg_character(x, .arg = rlang::caller_arg(x), .msg = NULL, .call)

arg_string(x, .arg = rlang::caller_arg(x), .msg = NULL, .call)

arg_factor(x, .arg = rlang::caller_arg(x), .msg = NULL, .call)
}
\arguments{
\item{x}{the argument to be checked}

\item{.arg}{the name of the argument supplied to \code{x} to appear in error messages. The default is to extract the argument's name using \code{\link[rlang:caller_arg]{rlang::caller_arg()}}. Ignored if \code{.msg} is supplied.}

\item{.msg}{an optional alternative message to display if an error is thrown instead of the default message.}

\item{.call}{the execution environment of a currently running function, e.g. \code{.call = rlang::current_env()}. The corresponding function call is retrieved and mentioned in error messages as the source of the error. Passed to \code{\link[=err]{err()}}. Set to \code{NULL} to omit call information. The default is to search along the call stack for the first user-facing function in another package, if any.}
}
\value{
Returns \code{NULL} invisibly if an error is not thrown.
}
\description{
Checks whether an argument is a character vector (\code{arg_character()}), a character scalar (\code{arg_string()}), or a factor (\code{arg_factor()}).
}
\details{
\code{NA} values in \code{arg_string()} will cause an error to be thrown.
}
\examples{
f <- function(z) {
  arg_string(z)
}

try(f("a")) # No error
try(f(c("a", "b"))) # Error: arg_string() requires scalar
try(f(NA)) # NAs not allowed for arg_string()
}
\seealso{
\code{\link[=is.character]{is.character()}}, \code{\link[=is.factor]{is.factor()}}, \code{\link[rlang:is_string]{rlang::is_string()}}
}
