Skip to main content

validate_component_glob

Function validate_component_glob 

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

Admission-time check that an IdentityMatcher component pattern is one component_glob_matches can honor: non-empty, no control characters, and none of the glob syntax this matcher deliberately does NOT support ([...] character classes, {...} brace expansion). Rejecting those up front beats silently matching them as literal characters — a data[0-9] that never matches anything is the silent-no-op failure mode this repo designs out.

Returns the human-readable reason on failure (the caller wraps it in ValidationError::InvalidFieldValue with the field path).

use kopiur_api::snapshot_replication::validate_component_glob;

assert!(validate_component_glob("pg-*").is_ok());
assert!(validate_component_glob("*").is_ok());
assert!(validate_component_glob("").is_err());
assert!(validate_component_glob("data[0-9]").is_err());
assert!(validate_component_glob("a{b,c}").is_err());