class Validators {
  Validators._();

  static String? required(String? value) {
    if (value == null || value.trim().isEmpty) return '此项为必填';
    return null;
  }

  static String? amount(String? value) {
    if (value == null || value.trim().isEmpty) return '请输入金额';
    final amount = double.tryParse(value);
    if (amount == null) return '请输入有效金额';
    if (amount <= 0) return '金额必须大于0';
    return null;
  }

  static String? maxLength(String? value, int max) {
    if (value != null && value.length > max) return '最多输入$max个字符';
    return null;
  }
}
