notEmpty method
Asserts that the field is not null or empty.
Implementation
PropertyRuleBuilder<T, V> notEmpty([String? customMessage]) {
_validators.add((val) {
if (val == null) return customMessage ?? 'Cannot be empty.';
if (val is String && val.trim().isEmpty) {
return customMessage ?? 'Cannot be empty.';
}
if (val is Iterable && val.isEmpty) {
return customMessage ?? 'Cannot be empty.';
}
return null;
});
return this;
}