RegistroCrc constructor
RegistroCrc({ - required String ufRegistro,
- required String numRegistro,
})
Implementation
RegistroCrc({required this.ufRegistro, required this.numRegistro}) {
if (ufRegistro.isEmpty) {
throw ArgumentError('UF do registro é obrigatória');
}
if (ufRegistro.length != 2) {
throw ArgumentError('UF do registro deve ter 2 caracteres');
}
if (!RegExp(r'^[A-Z]{2}$').hasMatch(ufRegistro)) {
throw ArgumentError(
'UF do registro deve conter apenas letras maiúsculas',
);
}
if (numRegistro.isEmpty) {
throw ArgumentError('Número do registro é obrigatório');
}
if (numRegistro.length < 6 || numRegistro.length > 11) {
throw ArgumentError(
'Número do registro deve ter entre 6 e 11 caracteres',
);
}
}