passes method
Validates the value using the given context.
Returns true if valid, otherwise false.
Implementation
@override
FutureOr<bool> passes(ValidationContext context) async {
final args = context.parameters;
final value = context.value;
final allowedTypes = _types?.map((e) => e.trim().toLowerCase()).toList() ??
args.map((e) => e.trim().toLowerCase()).toList();
if (value == null || allowedTypes.isEmpty) return false;
if (!await FileRule().passes(context)) return false;
if (value is UploadedFile) {
return _validateMime(value, allowedTypes);
} else if (value is List<UploadedFile>) {
for (final item in value) {
if (!await _validateMime(item, allowedTypes)) return false;
}
}
return true;
}