二次开发源码提交

This commit is contained in:
2026-05-15 08:52:48 +08:00
parent 4131f7321a
commit eb35a1d067
191 changed files with 34566 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
/// 字符串验证器
class StringValidator {
/// 验证邮箱
static String? validateEmail(String? value) {
if (value == null || value.isEmpty) {
return '请输入邮箱';
}
final emailRegex = RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$');
if (!emailRegex.hasMatch(value)) {
return '请输入有效的邮箱地址';
}
return null;
}
/// 验证密码
static String? validatePassword(String? value) {
if (value == null || value.isEmpty) {
return '请输入密码';
}
if (value.length < 6) {
return '密码长度至少为6位';
}
return null;
}
/// 验证必填
static String? validateRequired(String? value, {String message = '此字段不能为空'}) {
if (value == null || value.isEmpty) {
return message;
}
return null;
}
/// 验证昵称
static String? validateNickname(String? value) {
if (value == null || value.isEmpty) {
return '请输入昵称';
}
if (value.length > 50) {
return '昵称长度不能超过50个字符';
}
return null;
}
}