garde/rules/
mod.rs

1//! ## Validation rules
2
3pub mod alphanumeric;
4pub mod ascii;
5pub mod contains;
6#[cfg(feature = "credit-card")]
7pub mod credit_card;
8#[cfg(feature = "email")]
9pub mod email;
10pub mod inner;
11pub mod ip;
12pub mod length;
13pub mod matches;
14pub mod pattern;
15#[cfg(feature = "phone-number")]
16pub mod phone_number;
17pub mod prefix;
18pub mod range;
19pub mod required;
20pub mod suffix;
21#[cfg(feature = "url")]
22pub mod url;
23
24pub trait AsStr {
25    fn as_str(&self) -> &str;
26}
27
28impl AsStr for &str {
29    fn as_str(&self) -> &str {
30        self
31    }
32}
33
34impl AsStr for String {
35    fn as_str(&self) -> &str {
36        String::as_str(self)
37    }
38}
39
40impl AsStr for std::borrow::Cow<'_, str> {
41    fn as_str(&self) -> &str {
42        std::borrow::Cow::as_ref(self)
43    }
44}