FileRules class abstract final

Factory class for creating file validation rules.

Works with FileInfo objects for platform-agnostic validation.

Example

final avatarValidator = Validate.all<FileInfo, String>([
  FileRules.maxSize(5 * 1024 * 1024, error: 'Max 5MB'),
  FileRules.imageOnly(error: 'Only images allowed'),
]);

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

documentOnly<E>({required E error}) Rule<FileInfo, E>
Validates that the file is a document.
extension<E>(List<String> extensions, {required E error}) Rule<FileInfo, E>
Validates that the file has one of the allowed extensions.
imageOnly<E>({required E error}) Rule<FileInfo, E>
Validates that the file is an image.
maxSize<E>(int maxBytes, {required E error}) Rule<FileInfo, E>
Validates that the file size is at most maxBytes.
mimeType<E>(List<String> types, {required E error}) Rule<FileInfo, E>
Validates that the file has one of the allowed MIME types.
minSize<E>(int minBytes, {required E error}) Rule<FileInfo, E>
Validates that the file size is at least minBytes.
videoOnly<E>({required E error}) Rule<FileInfo, E>
Validates that the file is a video.