isChineseFullName property
bool
get
isChineseFullName
Returns true if name is a valid Chinese full name.
Rules:
- Length: 2 to 12 characters (common: 2–4)
- All characters must be valid Chinese characters (Unicode CJK range)
- Optional: allows '·' (U+00B7) for ethnic minority names like "买买提·艾买提"
Implementation
bool get isChineseFullName {
if (this.isEmpty) return false;
final trimmed = this!.trim();
if (trimmed.length < 2 || trimmed.length > 12) return false;
// Must consist only of CJK chars + optional single middle dot
final allowed = RegExp(r'^[\u4E00-\u9FFF·]+$');
if (!allowed.hasMatch(trimmed)) return false;
// Prevent all identical characters
if (trimmed.runes.toSet().length == 1) return false;
// Count dots
final dotCount = '·'.allMatches(trimmed).length;
if (dotCount > 1) return false; // only one dot allowed
if (dotCount == 0) {
return trimmed.length <= 4; // no dot && length → valid
}
// --- Dot is present: must be in the middle ---
final dotIndex = trimmed.indexOf('·');
// Not at start or end
if (dotIndex == 0 || dotIndex == trimmed.length - 1) return false;
// Must have at least one CJK char on each side
final left = trimmed.substring(0, dotIndex);
final right = trimmed.substring(dotIndex + 1);
if (left.isEmpty || right.isEmpty) return false;
// Both sides must contain only Chinese characters (no extra dots, already checked)
final cjkOnly = RegExp(r'^[\u4E00-\u9FFF]+$');
if (!cjkOnly.hasMatch(left) || !cjkOnly.hasMatch(right)) return false;
return true;
}