Skip to main content

okf_validator/
lib.rs

1//! # okf-validator: conformance checking and linting for OKF bundles
2//!
3//! Companion to [`okf-core`](https://docs.rs/okf-core), the pure-Rust
4//! implementation of the [Open Knowledge Format (OKF) v0.2][spec]. This crate
5//! judges bundles; okf-core models them.
6//!
7//! - [`validate`] checks conformance: [`validate_bundle`] reports only
8//!   true spec violations as [`Severity::Error`], with optional-family
9//!   problems surfaced as warnings and infos, never as rejections.
10//! - [`lint`] is the opinionated companion: [`lint_bundle`] goes beyond
11//!   conformance and flags the hygiene issues a continuously-authored corpus
12//!   drifts into, each finding tagged with a stable rule code.
13//!
14//! Staleness checks depend on the wall clock, so they are opt-in via
15//! [`validate_bundle_at`] and [`lint_bundle_at`], which take the date to
16//! compare against; the plain variants are deterministic.
17//!
18//! Most users get this crate through the [`okf`](https://docs.rs/okf) crate,
19//! which re-exports it alongside okf-core and ships the `okf` CLI.
20//!
21//! ```no_run
22//! use okf_core::Bundle;
23//! use okf_validator::validate_bundle;
24//!
25//! let bundle = Bundle::load("./my_bundle")?;
26//! let report = validate_bundle(&bundle);
27//! if report.is_conformant() {
28//!     println!("conformant OKF v0.2 bundle");
29//! }
30//! # Ok::<(), okf_core::BundleError>(())
31//! ```
32//!
33//! [spec]: https://github.com/GoogleCloudPlatform/open-knowledge-format/blob/main/SPEC.md
34
35#![forbid(unsafe_code)]
36#![warn(missing_docs)]
37// Pedantic and nursery lints keep the published crate tidy; the few cases
38// where a lint is genuinely wrong for this codebase are silenced inline with a
39// justification.
40#![warn(clippy::pedantic, clippy::nursery)]
41
42pub mod lint;
43pub mod validate;
44
45#[doc(inline)]
46pub use lint::{lint_bundle, lint_bundle_at};
47#[doc(inline)]
48pub use validate::{Diagnostic, Report, Severity, validate_bundle, validate_bundle_at};