zino_core/validation/validator/regex.rs
1use super::Validator;
2use regex::{Error, Regex};
3use std::str::FromStr;
4
5/// A validator for regular expressions.
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub struct RegexValidator;
8
9impl Validator<str> for RegexValidator {
10 type Error = Error;
11
12 #[inline]
13 fn validate(&self, data: &str) -> Result<(), Self::Error> {
14 Regex::from_str(data)?;
15 Ok(())
16 }
17}