validators 0.26.0

This library is designed for validating and modeling user input. The crate includes models, functions, traits, errors, and other dependencies.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/// Determine whether the input domain is localhost.
#[inline]
pub fn is_local_domain<S: AsRef<str>>(s: S) -> bool {
    let s = s.as_ref();

    s.strip_suffix('.').unwrap_or(s).eq_ignore_ascii_case("localhost")
}

/// Determine whether the input domain is has at least two labels.
#[inline]
pub fn is_at_least_two_labels_domain<S: AsRef<str>>(s: S) -> bool {
    let s = s.as_ref();

    s.strip_suffix('.').unwrap_or(s).contains('.')
}