fsvalidator 0.1.2

A file structure validator
Documentation
fsvalidator-0.1.2 has been yanked.

File Structure Validator

A Rust library for validating real filesystem directories against a declarative, strongly-typed schema. Useful for enforcing project structure, data ingestion layout, or configuration rules.

Features

  • Strongly-typed node model with Literal and regex Pattern matching.
  • Supports nested directory/file trees.
  • Shared template support via references.
  • Optional validation strictness (required, allow_defined_only).
  • Built-in validation with informative errors.

Example

use fsvalidator::from_toml;

fn main() -> Result<()> {
    let root = from_toml("examples/basic/fsvalidator.toml")?;
    println!("{root}");
    root.validate("./examples")?;

    Ok(())
}

Model Overview

enum Node {
    Dir(Rc<RefCell<DirNode>>),
    File(Rc<RefCell<FileNode>>),
}

struct DirNode {
    name: NodeName,
    children: Vec<Node>,
    required: bool,
    allow_defined_only: bool,
}

struct FileNode {
    name: NodeName,
    required: bool,
}

enum NodeName {
    Literal(String),
    Pattern(String), // Regex
}

Use Cases

  • Project layout enforcement
  • Data pipeline input verification
  • Config tree validation

Installation

Add to Cargo.toml:

[dependencies]
validator = { fsvalidator = "0.1.2" }

License

MIT