validate method

  1. @override
bool validate(
  1. dynamic value, [
  2. List<String>? options
])
override

Validates whether the file's MIME type is allowed.

This method checks if the value is an instance of MultipartFile and if the MIME type of the file is one of the allowed types specified in the options.

value - The value to be validated. options - A list containing the allowed MIME types as strings.

Returns true if the MIME type is allowed, otherwise false.

Implementation

@override
bool validate(dynamic value, [List<String>? options]) {
  if (value is! MultipartFile || options == null || options.isEmpty) {
    return false;
  }
  final allowedTypes = options;
  return allowedTypes.contains(value.contentType);
}