FilesValidator class
Framework\Validation\FilesValidator
Class FilesValidator.
Defined in libraries/validation/src/FilesValidator.php
Properties #
- $files
- -
$files
protected static array $files
Methods #
- dim()
- Validates image dimensions.
- ext()
- Validates file accepted extensions.
- image()
- Validates file is an image.
- maxDim()
- Validates image max dimensions.
- maxSize()
- Validates file size.
- mimes()
- Validates file accepted MIME types.
- minDim()
- Validates image min dimensions.
- uploaded()
- Validates file is uploaded.
- getFile()
- -
- getOrganizedFiles()
- Get $_FILES in a re-organized way.
dim()
public static function dim(string $field, array $data, int $width, int $height): bool
Validates image dimensions.
Parameters
- string $field
- array $data
- int $width
- int $height
Returns
bool
ext()
public static function ext(string $field, array $data, string ...$allowedExtensions): bool
Validates file accepted extensions.
NOTE: For greater security use the {@see FilesValidator::mimes()} method
to filter the file type.
Parameters
- string $field
- array $data
- string $allowedExtensions
Returns
bool
image()
public static function image(string $field, array $data = array (
)): bool
Validates file is an image.
Parameters
- string $field
- array $data
Returns
bool
maxDim()
public static function maxDim(string $field, array $data, int $width, int $height): bool
Validates image max dimensions.
Parameters
- string $field
- array $data
- int $width
- int $height
Returns
bool
maxSize()
public static function maxSize(string $field, array $data, int $kilobytes): bool
Validates file size.
Parameters
- string $field
- array $data
- int $kilobytes
Returns
bool
mimes()
public static function mimes(string $field, array $data, string ...$allowedTypes): bool
Validates file accepted MIME types.
Parameters
- string $field
- array $data
- string $allowedTypes
Returns
bool
minDim()
public static function minDim(string $field, array $data, int $width, int $height): bool
Validates image min dimensions.
Parameters
- string $field
- array $data
- int $width
- int $height
Returns
bool
uploaded()
public static function uploaded(string $field, array $data = array (
)): bool
Validates file is uploaded.
Parameters
- string $field
- array $data
Returns
bool
getFile()
protected static function getFile(string $field): ?array
Parameters
- string $field
Returns
?array
getOrganizedFiles()
protected static function getOrganizedFiles(): array
Get $_FILES in a re-organized way.
Returns
array