validate method

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

Validates whether the file size does not exceed the specified limit.

This method checks if the value is an instance of MultipartFile and if the file size is less than or equal to the maximum size specified in the options.

value - The value to be validated. options - A list containing the maximum file size as a string.

Returns true if the file size does not exceed the limit, otherwise false.

Implementation

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