isBetween method
Notifica se value NÃO estiver entre from e into (inclusivo).
Implementation
ContractValidations isBetween(dynamic value, dynamic from, dynamic into,
String property, String message) {
final hasDatetime =
(value is DateTime) || (from is DateTime) || (into is DateTime);
if (hasDatetime) {
final dt = value as DateTime;
final isInRange =
(dt.isAfter(from as DateTime) || dt.isAtSameMomentAs(from)) &&
(dt.isBefore(into as DateTime) || dt.isAtSameMomentAs(into));
if (!isInRange) {
addNotifications(
ValidationNotification(property: property, message: message));
}
return this;
}
if (value < from || value > into) {
addNotifications(
ValidationNotification(property: property, message: message));
}
return this;
}