Skip to main content

validate_alias_key

Function validate_alias_key 

Source
pub fn validate_alias_key(key: &str) -> Result<(), String>
Expand description

Validate that an alias key is safe for use in TOML dotted paths, URLs, filesystem paths on Windows/macOS/Linux, and ZEROCLAW_* env-var grammar.

Allowed: lowercase ASCII alphanumeric plus single underscore, 1-63 chars. Must start AND end with alphanumeric. Adjacent underscores (__) are forbidden because they collide with the env-var grammar’s path separator.

The env-var grammar uses __ as path separator, which lets aliases keep single _ literally (prod_v2, staging_api). Hyphens are forbidden because they are illegal in POSIX env-var identifiers; uppercase is forbidden so the bootstrap env-vars (ZEROCLAW_WORKSPACE, ZEROCLAW_CONFIG_DIR) stay disambiguated by case.