pub fn matches_pattern(value: &str, pattern: &str) -> boolExpand description
Check if a string matches a regex pattern.
This function compiles the regex on each call, which is fine for validation but may not be ideal for hot paths. Consider caching the compiled regex if validating many values.
ยงExamples
use fastapi_core::validation::matches_pattern;
// Simple exact match patterns (no regex features)
assert!(matches_pattern("hello", r"^hello$"));
assert!(!matches_pattern("world", r"^hello$"));
assert!(matches_pattern("anything", "")); // Empty pattern matches all