pub fn check_min_length(value: &str, min: usize) -> bool {
value.len() >= min
}
pub fn check_max_length(value: &str, max: usize) -> bool {
value.len() <= max
}
pub fn check_between_length(value: &str, min: usize, max: usize) -> bool {
let len = value.len();
len >= min && len <= max
}
pub fn check_size(value: &str, size: usize) -> bool {
value.len() == size
}
pub fn is_alpha(value: &str) -> bool {
!value.is_empty() && value.chars().all(|c| c.is_alphabetic())
}
pub fn is_alpha_num(value: &str) -> bool {
!value.is_empty() && value.chars().all(|c| c.is_alphanumeric())
}
pub fn is_alpha_dash(value: &str) -> bool {
!value.is_empty()
&& value
.chars()
.all(|c| c.is_alphanumeric() || c == '-' || c == '_')
}
pub fn is_numeric(value: &str) -> bool {
value.parse::<f64>().is_ok()
}
pub fn is_integer(value: &str) -> bool {
value.parse::<i64>().is_ok()
}
pub fn starts_with(value: &str, prefix: &str) -> bool {
value.starts_with(prefix)
}
pub fn ends_with(value: &str, suffix: &str) -> bool {
value.ends_with(suffix)
}
pub fn doesnt_start_with(value: &str, prefix: &str) -> bool {
!value.starts_with(prefix)
}
pub fn doesnt_end_with(value: &str, suffix: &str) -> bool {
!value.ends_with(suffix)
}
pub fn contains(value: &str, needle: &str) -> bool {
value.contains(needle)
}
pub fn doesnt_contain(value: &str, needle: &str) -> bool {
!value.contains(needle)
}
pub fn is_uppercase(value: &str) -> bool {
!value.is_empty() && value == value.to_uppercase()
}
pub fn is_lowercase(value: &str) -> bool {
!value.is_empty() && value == value.to_lowercase()
}