EncodedFileValidator
API reference › FilePond › validator › EncodedFileValidator
Validates FilePond File Encode payloads by inspecting the decoded content on the server.
Extensions are checked against the client file name, MIME types against the bytes through finfo, and sizes
against the decoded content, so client-side plugin settings are never trusted. The inherited $message, shown
for a malformed payload, defaults to a translated message of the yii.filepond category.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$attributeNames read-only | array | Attribute names. | yii\ |
$attributes | array| | Attributes to be validated by this validator. Default: []. | yii\ |
$behaviors read-only | array<yii\<static>> | List of behaviors attached to this component. | yii\ |
$builtInValidators static | array | List of built-in validators (name => class or configuration) Default: ['boolean' => 'yii\. | yii\ |
$enableClientValidation | bool | Whether to enable client-side validation for this validator. Default: true. | yii\ |
$except | array| | Scenarios that the validator should not be applied to. Default: []. | yii\ |
$extensions | list<string>| | Allowed lowercase extensions, as a list or a comma-separated string, or null to accept any extension. Default: null. | EncodedFileValidator |
$isEmpty | callable| | A PHP callable that replaces the default implementation of isEmpty(). Default: null. | yii\ |
$maxFiles | int | Maximum number of files, or 0 for no limit. Default: 1. | EncodedFileValidator |
$maxSize | int| | Maximum file size in bytes, or null for no limit. Default: null. | EncodedFileValidator |
$message | string| | The user-defined error message. Default: null. | yii\ |
$mimeTypes | list<string>| | Allowed MIME types with optional wildcards such as image/*, or null to accept any type. Default: null. | EncodedFileValidator |
$minSize | int| | Minimum file size in bytes, or null for no limit. Default: null. | EncodedFileValidator |
$on | array| | Scenarios that the validator can be applied to. Default: []. | yii\ |
$skipOnEmpty | bool | Whether this validation rule should be skipped if the attribute value is null or an empty string. Default: true. | yii\ |
$skipOnError | bool | Whether this validation rule should be skipped if the attribute being validated already has some validation error according to some previous rules. Default: true. | yii\ |
$tooBig | string | Error message for files larger than $maxSize. Supports {file} and {formattedLimit}; empty for the Yii default. Default: ''. | EncodedFileValidator |
$tooMany | string | Error message for more files than $maxFiles. Supports {limit}; empty for the Yii default. Default: ''. | EncodedFileValidator |
$tooSmall | string | Error message for files smaller than $minSize. Supports {file} and {formattedLimit}; empty for the Yii default. Default: ''. | EncodedFileValidator |
$uploadRequired | string | Error message for a required attribute without files; empty for the Yii default. Default: ''. | EncodedFileValidator |
$validationAttributes read-only | array| | List of attribute names. | yii\ |
$when | callable| | A PHP callable whose return value determines whether this validator should be applied. Default: null. | yii\ |
$whenClient | string| | A JavaScript function name whose return value determines whether this validator should be applied on the client-side. Default: null. | yii\ |
$wrongExtension | string | Error message for a disallowed extension. Supports {file} and {extensions}; empty for the Yii default. Default: ''. | EncodedFileValidator |
$wrongMimeType | string | Error message for a disallowed MIME type. Supports {file} and {mimeTypes}; empty for the Yii default. Default: ''. | EncodedFileValidator |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Constructor. | yii\ |
__call() | Calls the named method which is not a class method. | yii\ |
__clone() | This method is called after the object is created by cloning an existing one. | yii\ |
__get() | Returns the value of a component property. | yii\ |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\ |
__set() | Sets the value of a component property. | yii\ |
__unset() | Sets a component property to be null. | yii\ |
addError() | Adds an error about the specified attribute to the model object. | yii\ |
attachBehavior() | Attaches a behavior to this component. | yii\ |
attachBehaviors() | Attaches a list of behaviors to the component. | yii\ |
behaviors() | Returns a list of behaviors that this component should behave as. | yii\ |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\ |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\ |
className() static | Returns the fully qualified name of this class. | yii\ |
clientValidateAttribute() | Returns the JavaScript needed for performing client-side validation. | yii\ |
createValidator() static | Creates a validator object. | yii\ |
detachBehavior() | Detaches a behavior from the component. | yii\ |
detachBehaviors() | Detaches all behaviors from the component. | yii\ |
ensureBehaviors() | Makes sure that the behaviors declared in behaviors() are attached to this component. | yii\ |
getAttributeNames() | Returns cleaned attribute names without the ! character at the beginning. | yii\ |
getBehavior() | Returns the named behavior object. | yii\ |
getBehaviors() | Returns all behaviors attached to this component. | yii\ |
getClientOptions() | Returns the client-side validation options. | yii\ |
getFormattedClientMessage() | Returns the formatted validation message for client-side validation. | yii\ |
getValidationAttributes() | Returns a list of attributes this validator applies to. | yii\ |
hasEventHandlers() | Returns a value indicating whether there is any handler attached to the named event. | yii\ |
hasMethod() | Returns a value indicating whether a method is defined. | yii\ |
hasProperty() | Returns a value indicating whether a property is defined for this component. | yii\ |
init() | EncodedFileValidator | |
isActive() | Returns a value indicating whether the validator is active for the given scenario and attribute. | yii\ |
isEmpty() | EncodedFileValidator | |
off() | Detaches an existing event handler from this component. | yii\ |
on() | Attaches an event handler to an event. | yii\ |
trigger() | Triggers an event. | yii\ |
validate() | Validates a given value. | yii\ |
validateAttribute() | Validates a single attribute. | yii\ |
validateAttributes() | Validates the specified object. | yii\ |
formatMessage() protected | Formats a mesage using the I18N, or simple strtr if \ is not available. | yii\ |
validateValue() protected | EncodedFileValidator |
Method details
Section titled “Method details”init()
Section titled “init() ”public function init(): voidisEmpty()
Section titled “isEmpty() ”public function isEmpty(mixed $value): boolParameters
| Parameter | Type | Description |
|---|---|---|
$value | mixed | Request value of the FilePond input. |
Returns
bool
validateValue()
Section titled “validateValue() ”protected function validateValue(mixed $value): array{0: string, 1: array<string, mixed>}|nullParameters
| Parameter | Type | Description |
|---|---|---|
$value | mixed | Request value of the FilePond input. |
Returns
array{0: string, 1: array<string, mixed>}|null: Error message and parameters, or null when valid.