perfgate-validation
Schema validation and contract testing for benchmark names in perfgate.
Part of the perfgate workspace.
Problem
Benchmark names appear in file paths, JSON keys, and REST URLs. A bad name (path traversal, illegal characters, excessive length) can break storage, confuse queries, or open security holes. This crate provides a single validation entry point that enforces strict naming rules everywhere.
Naming Rules
- Must not be empty.
- Maximum 64 characters (
BENCH_NAME_MAX_LEN). - Lowercase ASCII letters, digits,
_,.,-,/only (BENCH_NAME_PATTERN). - No empty path segments -- leading, trailing, or consecutive
/forbidden. - No
.or..segments -- path traversal forbidden.
Key API
validate_bench_name(name)-- returnsOk(())or aValidationErrorValidationError-- enum:Empty,TooLong,InvalidCharacters,EmptySegment,PathTraversalBENCH_NAME_MAX_LEN--64BENCH_NAME_PATTERN--^[a-z0-9_.\-/]+$
All types are re-exported from perfgate-error for a focused, dependency-light
entry point.
Example
use ;
assert!;
assert!;
assert!;
assert!;
assert!;
License
Licensed under either Apache-2.0 or MIT.