import 'package:easy_localization/easy_localization.dart';
import 'package:intl/intl.dart';

class CertificateDateValidator {
  CertificateDateValidator._();

  static String? validate(String value) {
    try {
      final date = DateFormat('MM.dd.yyyy').parse(value);
      var splited = value.split('.');
      if (int.parse(splited.first) > 12 || int.parse(splited[1]) > 31) {
        return 'invalid_date_format'.tr();
      }

      if (date.isBefore(DateTime.now())) {
        return 'date_cannot_be_past'.tr();
      }
    } catch (e) {
      return null;
    }
    return null;
  }
}
