videoOnly<E> static method
Validates that the file is a video.
Checks for common video extensions and MIME types.
FileRules.videoOnly(error: 'Only videos allowed')
Implementation
static Rule<FileInfo, E> videoOnly<E>({required E error}) {
const videoExtensions = ['mp4', 'mov', 'avi', 'mkv', 'webm', 'flv', 'wmv'];
return PredicateRule(
predicate: (value) {
if (value.mimeType != null) {
return value.mimeType!.startsWith('video/');
}
return videoExtensions.contains(value.extension);
},
error: error,
);
}