Expand description
§FSValidator
A library for validating filesystem structures against a declarative schema.
This crate allows you to define expected file and directory structures and validate that real filesystem paths match those expectations. It’s useful for ensuring project layouts, validating data directories, or enforcing configuration structures.
§Features
- Validate files and directories using literal names or regex patterns
- Support for complex nested directory structures
- Template system for reusing common structures
- Control validation strictness with required flags and restricted directories
- Load definitions from TOML or JSON files
§Example
use anyhow::Result;
use fsvalidator::from_toml;
fn main() -> Result<()> {
// Load structure definition from TOML
let root = from_toml("path/to/fsvalidator.toml")?;
// Validate a directory against the defined structure
root.validate("./path/to/validate")?;
Ok(())
}§Schema Definition
The schema can be defined in TOML or JSON, with a structure like this:
[root]
type = "dir"
name = "project"
required = true
[[root.children]]
type = "file"
name = "README.md"
required = true
[[root.children]]
type = "dir"
name = "src"
required = true
[[root.children.children]]
type = "file"
pattern = ".*\.rs"
required = true