% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cff_validate.R
\encoding{UTF-8}
\name{cff_validate}
\alias{cff_validate}
\title{Validate a \code{CITATION.cff} file or a \code{\link{cff}} object}
\usage{
cff_validate(x = "CITATION.cff", verbose = TRUE)
}
\arguments{
\item{x}{This is expected to be either a full \code{cff} object created
with \code{\link[=cff_create]{cff_create()}} or the path to a \code{CITATION.cff} file to be validated.
In the case of a \verb{*.cff} file it would read with \code{\link[=cff_read_cff_citation]{cff_read_cff_citation()}}.}

\item{verbose}{Logical \code{TRUE/FALSE}. When \code{TRUE}, the function displays
informative messages.}
}
\value{
A message indicating the result of the validation and an invisible value
\code{TRUE/FALSE}. On error, the result has an attribute \code{"errors"}
containing the error summary (see \strong{Examples} and \code{\link[=attr]{attr()}}).
}
\description{
Validate a \code{CITATION.cff} file or a \code{\link{cff}} object using the corresponding \href{https://github.com/citation-file-format/citation-file-format/blob/main/schema.json}{validation schema}.
}
\examples{
\donttest{
# Full .cff example
cff_validate(system.file("examples/CITATION_complete.cff", package = "cffr"))

# Validate a cffr object
cffr <- cff_create("jsonlite")
class(cffr)
cff_validate(cffr)
}

# .cff with errors
err_f <- system.file("examples/CITATION_error.cff", package = "cffr")
# Can manipulate the errors as data frame
res <- try(cff_validate(err_f))

isTRUE(res)
isFALSE(res)

# Detailed results
df_errors <- attr(res, "errors")

df_errors[, c("field", "message")]

# If a CITATION file is supplied (note that it is not a .cff file), it
# throws an error
try(cff_validate(system.file("CITATION", package = "cffr")))
}
\seealso{
\href{https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md}{Guide to Citation File Format schema version 1.2.0}.

\code{\link[jsonvalidate:json_validate]{jsonvalidate::json_validate()}}, which is the function that performs the
validation.

Other core functions of \CRANpkg{cffr}:
\code{\link[=cff]{cff()}},
\code{\link[=cff_create]{cff_create()}},
\code{\link[=cff_modify]{cff_modify()}}
}
\concept{core}
