maxFileSize function
Creates a validator for BloomFileField that fails when any file exceeds maxBytes.
Returns message (or 'File size exceeds maximum allowed limit of $maxBytes bytes.' by default).
final avatarField = BloomFileField(
validators: [maxFileSize(2 * 1024 * 1024, 'Avatar must be under 2MB.')],
);
Implementation
String? Function(List<BloomFile>) maxFileSize(int maxBytes, [String? message]) =>
(files) => files.any((f) => f.size > maxBytes)
? (message ??
'File size exceeds maximum allowed limit of $maxBytes bytes.')
: null;