pub mod case;
pub mod color;
use crate::{prelude::*, visitor::Validator};
#[validator]
pub struct AlphaUscore;
impl Validator<str> for AlphaUscore {
fn validate(&self, s: &str, ctx: &mut dyn VisitorContext) {
if !s.chars().all(|c| c.is_alphabetic() || c == '_') {
ctx.issue("text must be alphabetic or underscore");
}
}
}
#[validator]
pub struct AlphanumUscore;
impl Validator<str> for AlphanumUscore {
fn validate(&self, s: &str, ctx: &mut dyn VisitorContext) {
if !s.chars().all(|c| c.is_alphanumeric() || c == '_') {
ctx.issue("text must be alphanumeric or underscore");
}
}
}
#[validator]
pub struct Ascii;
impl Validator<str> for Ascii {
fn validate(&self, s: &str, ctx: &mut dyn VisitorContext) {
if !s.is_ascii() {
ctx.issue("text must be ASCII");
}
}
}