ratesValidator function
Implementation
String? ratesValidator(
String? numberWithDecimal, {
required List<String> rates,
}) {
if (numberWithDecimal != null) {
if (numberWithDecimal == '0' || numberWithDecimal == '0.0') {
return 'La tarifa debe ser mayor a Bs. 0';
} else if (rates.contains(numberWithDecimal)) {
return 'Ya ingresó esta tarifa';
} else if (!_numberWithDecimalRegExp.hasMatch(numberWithDecimal) ||
(numberWithDecimal.characters.first == '0' &&
!numberWithDecimal.contains('.'))) {
return 'Ingrese un número válido';
} else {
return null;
}
}
return null;
}