pub fn validate(glob: impl AsRef<[u8]>) -> Result<(), Error>Expand description
Checks that glob is a valid pattern.
glob_match has no way to report an invalid pattern, and its result for
one is unspecified. Call this once when a pattern is first accepted (e.g.
at configuration load time) to reject invalid patterns with an actionable
error instead of silently matching nothing.
A pattern accepted here is never treated as invalid by glob_match, so
its matching behavior is well-defined. For a rejected pattern the result
of glob_match is unspecified — typically it matches nothing.
§Examples
use fast_glob::{validate, Error, ErrorKind};
assert!(validate("some/**/n*d[k-m]e?txt").is_ok());
assert_eq!(
validate("src/**/*.{js,ts"),
Err(Error { kind: ErrorKind::UnclosedBrace, index: 9 })
);