cff_validate: Validate a 'CITATION.cff' file or a 'cff' object

View source: R/cff-validate.R

cff_validateR Documentation

Validate a CITATION.cff file or a cff object

Description

Validate a CITATION.cff file or a cff object using the corresponding validation schema.

Usage

cff_validate(x = "CITATION.cff", verbose = TRUE)

Arguments

x

A full cff object created with cff_create() or the path to a CITATION.cff file to be validated. A ⁠*.cff⁠ file is read with cff_read_cff_citation().

verbose

A logical value. If TRUE, the function displays informative messages.

Value

Invisibly returns a logical value indicating the validation result. On error, the result has an "errors" attribute with the error summary. If verbose is TRUE, the function also displays the result. See Examples and base::attr().

See Also

jsonvalidate::json_validate(), which is the function that performs the validation.

Citation File Format schema guide.

Core cffr workflow: cff(), cff_create(), cff_modify(), cff_write()

Examples


# Full `.cff` example.
cff_validate(system.file("examples/CITATION_complete.cff", package = "cffr"))

# Validate a `cff` object.
cffr <- cff_create("jsonlite")
class(cffr)
cff_validate(cffr)


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

isTRUE(res)
isFALSE(res)

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

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

# An R citation file is not a `.cff` file, so it throws an error.
try(cff_validate(system.file("CITATION", package = "cffr")))

cffr documentation built on Aug. 24, 2026, 5:11 p.m.