feat(core): add theme, shared widgets and validators

This commit is contained in:
qzl
2026-02-25 10:52:18 +08:00
parent febd10d64e
commit 8c0b0a25c3
8 changed files with 389 additions and 2 deletions
+41
View File
@@ -0,0 +1,41 @@
class Validators {
Validators._();
static String? email(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? password(String? value) {
if (value == null || value.isEmpty) {
return '请输入密码';
}
if (value.length < 8) {
return '密码至少需要8位';
}
return null;
}
static String? required(String? value, [String? fieldName]) {
if (value == null || value.isEmpty) {
return '请输入${fieldName ?? '内容'}';
}
return null;
}
static String? nickname(String? value) {
if (value == null || value.isEmpty) {
return '请输入昵称';
}
if (value.length < 2) {
return '昵称至少需要2个字符';
}
return null;
}
}