Skip to content

ImagesValidator

Use ImagesValidator for galleries, attachments, or any field containing multiple uploaded images.

Rule::images(string $field): ImagesValidator
MethodDescription
`min(intfloat $value)`
`max(intfloat $value)`
maxFileSizeMB(int $megabytes)Set the per-file size limit.
validate(mixed $value)Validate the upload collection.
required(bool $required = true)Require at least one upload.
optional()Allow the collection to be missing.
use Fynix\Rule;
$validator = Rule::images('gallery')
->min(1)
->max(8)
->maxFileSizeMB(5);
$errors = $validator->validateFieldAll($_FILES['gallery'] ?? null);

Each image is checked using the same content and upload checks as ImageValidator. Count limits must be non-negative integers.