pub struct Valid;Expand description
通用验证工具
提供邮箱、手机号、URL、数字、字母数字、长度范围、 密码强度、IPv4、Base64、UUID、身份证、日期、JSON 等常用格式的布尔校验方法。
Implementations§
Source§impl Valid
impl Valid
Sourcepub fn is_username(s: &str) -> bool
pub fn is_username(s: &str) -> bool
验证用户名(3~50 位字母、数字、下划线、点、横线)
Sourcepub fn is_alphanumeric(s: &str) -> bool
pub fn is_alphanumeric(s: &str) -> bool
验证是否为字母+数字组合
Sourcepub fn is_strong_password(s: &str) -> bool
pub fn is_strong_password(s: &str) -> bool
验证密码强度(至少 8 位,包含大小写+数字+特殊字符)
Sourcepub fn is_id_card(s: &str) -> bool
pub fn is_id_card(s: &str) -> bool
验证中国居民身份证号(含校验位)
Sourcepub fn is_datetime(s: &str) -> bool
pub fn is_datetime(s: &str) -> bool
验证日期时间格式(ISO 8601 / RFC 3339 或 YYYY-MM-DD)
Sourcepub fn is_html_free(s: &str) -> bool
pub fn is_html_free(s: &str) -> bool
检测字符串是否不包含 HTML 标签
Sourcepub fn is_file_extension(filename: &str, allowed: &[&str]) -> bool
pub fn is_file_extension(filename: &str, allowed: &[&str]) -> bool
验证文件扩展名是否在允许列表中
Auto Trait Implementations§
impl Freeze for Valid
impl RefUnwindSafe for Valid
impl Send for Valid
impl Sync for Valid
impl Unpin for Valid
impl UnsafeUnpin for Valid
impl UnwindSafe for Valid
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more