Skip to main content

validate_with_schema

Function validate_with_schema 

Source
pub fn validate_with_schema(
    content_dir: &Path,
    schema_path: &Path,
) -> Result<()>
Expand description

Validates every .md file under content_dir against the schema at schema_path.

Use this entry point when the schema must live outside content_dir — for example, because staticdatagen::compile reads every file in content_dir and would fail to parse a non-Markdown schema file as content.

§Examples

use ssg::content::validate_with_schema;
use tempfile::tempdir;

let dir = tempdir().unwrap();
// Missing schema path is treated as "nothing to enforce".
assert!(validate_with_schema(dir.path(), &dir.path().join("schema.toml")).is_ok());

§Errors

Returns Err if the schema can’t be loaded or any content file fails validation.