WordPress\AiClient\Files\ValueObjects
MimeType::isValid
Checks if a MIME type string is valid.
Method of the class: MimeType{}
No Hooks.
Returns
true|false. True if valid.
Usage
$result = MimeType::isValid( $mimeType ): bool;
- $mimeType(string) (required)
- The MIME type to validate.
Changelog
| Since 0.1.0 | Introduced. |
MimeType::isValid() MimeType::isValid code WP 7.0
public static function isValid(string $mimeType): bool
{
// Basic MIME type validation: type/subtype
return (bool) preg_match('/^[a-zA-Z0-9][a-zA-Z0-9!#$&\-\^_+.]*\/[a-zA-Z0-9][a-zA-Z0-9!#$&\-\^_+.]*$/', $mimeType);
}