ImagesValidator
ImagesValidator
Section titled “ImagesValidator”Use ImagesValidator for galleries, attachments, or any field containing multiple uploaded images.
Create a rule
Section titled “Create a rule”Rule::images(string $field): ImagesValidatorMethods
Section titled “Methods”| Method | Description |
|---|---|
| `min(int | float $value)` |
| `max(int | float $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. |
Example
Section titled “Example”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.