Skip to content
Corex

MimeType

Corex\Forms\Validation\Rules\MimeType · class · Forms layer

An uploaded file is one of the types this field accepts (spec 081, FR-003). Reads the file’s content, through WordPress’s own wp_check_filetype_and_ext(), not the type the browser declared — that is set by the client and is worth exactly as much as any other client assertion. A .pdf that is really a .php is caught here, before anything is stored. Written as mime:application/pdf,image/png. Empty is deferred to required, as every rule here does, so an optional upload stays possible.

validate(mixed $value, array $params, array $allValues): ?string

Section titled “validate(mixed $value, array $params, array $allValues): ?string”