isValidPeriodoApuracao static method
Valida se o período de apuração está no formato correto (ano, mês opcional, dia opcional)
ano - Ano com 4 dígitos
mes - Mês com 2 dígitos (opcional)
dia - Dia com 2 dígitos (opcional)
Implementation
static bool isValidPeriodoApuracao(String ano, String? mes, String? dia) {
// Validar ano
if (!isValidAno(ano)) return false;
// Validar mês se fornecido
if (mes != null && mes.isNotEmpty) {
if (mes.length != 2 || int.tryParse(mes) == null) return false;
final mesInt = int.parse(mes);
if (mesInt < 1 || mesInt > 12) return false;
}
// Validar dia se fornecido
if (dia != null && dia.isNotEmpty) {
if (dia.length != 2 || int.tryParse(dia) == null) return false;
final diaInt = int.parse(dia);
if (diaInt < 1 || diaInt > 31) return false;
}
return true;
}