Skip to content
PHP Ecosystem
Explore

EncodedFileValidator

API reference › FilePond › validator › EncodedFileValidator

final classyii2\extensions\filepond\validator\EncodedFileValidator
Extendsyii\validators\Validator » yii\base\Component » yii\base\BaseObject
Implementsyii\base\Configurable
Sourcesrc/validator/EncodedFileValidator.php

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.

PropertyTypeDescriptionDefined by
$attributeNames read-onlyarrayAttribute names.yii\validators\Validator
$attributesarray|stringAttributes to be validated by this validator. Default: [].yii\validators\Validator
$behaviors read-onlyarray<yii\base\Behavior<static>>List of behaviors attached to this component.yii\base\Component
$builtInValidators staticarrayList of built-in validators (name => class or configuration) Default: ['boolean' => 'yii\validators\BooleanValidator', 'captcha' => 'yii\captcha\CaptchaValidator', 'compare' => 'yii\validators\CompareValidator', 'date' => 'yii\validators\DateValidator', 'datetime' => ['class' => 'yii\validators\DateValidator', 'type' => \yii\validators\DateValidator::TYPE_DATETIME], 'time' => ['class' => 'yii\validators\DateValidator', 'type' => \yii\validators\DateValidator::TYPE_TIME], 'default' => 'yii\validators\DefaultValueValidator', 'double' => 'yii\validators\NumberValidator', 'each' => 'yii\validators\EachValidator', 'email' => 'yii\validators\EmailValidator', 'exist' => 'yii\validators\ExistValidator', 'file' => 'yii\validators\FileValidator', 'filter' => 'yii\validators\FilterValidator', 'image' => 'yii\validators\ImageValidator', 'in' => 'yii\validators\RangeValidator', 'integer' => ['class' => 'yii\validators\NumberValidator', 'integerOnly' => true], 'match' => 'yii\validators\RegularExpressionValidator', 'number' => 'yii\validators\NumberValidator', 'required' => 'yii\validators\RequiredValidator', 'safe' => 'yii\validators\SafeValidator', 'string' => 'yii\validators\StringValidator', 'trim' => ['class' => 'yii\validators\TrimValidator', 'skipOnArray' => true], 'unique' => 'yii\validators\UniqueValidator', 'url' => 'yii\validators\UrlValidator', 'ip' => 'yii\validators\IpValidator'].yii\validators\Validator
$enableClientValidationboolWhether to enable client-side validation for this validator. Default: true.yii\validators\Validator
$exceptarray|stringScenarios that the validator should not be applied to. Default: [].yii\validators\Validator
$extensionslist<string>|string|nullAllowed lowercase extensions, as a list or a comma-separated string, or null to accept any extension. Default: null.EncodedFileValidator
$isEmptycallable|nullA PHP callable that replaces the default implementation of isEmpty(). Default: null.yii\validators\Validator
$maxFilesintMaximum number of files, or 0 for no limit. Default: 1.EncodedFileValidator
$maxSizeint|nullMaximum file size in bytes, or null for no limit. Default: null.EncodedFileValidator
$messagestring|nullThe user-defined error message. Default: null.yii\validators\Validator
$mimeTypeslist<string>|string|nullAllowed MIME types with optional wildcards such as image/*, or null to accept any type. Default: null.EncodedFileValidator
$minSizeint|nullMinimum file size in bytes, or null for no limit. Default: null.EncodedFileValidator
$onarray|stringScenarios that the validator can be applied to. Default: [].yii\validators\Validator
$skipOnEmptyboolWhether this validation rule should be skipped if the attribute value is null or an empty string. Default: true.yii\validators\Validator
$skipOnErrorboolWhether this validation rule should be skipped if the attribute being validated already has some validation error according to some previous rules. Default: true.yii\validators\Validator
$tooBigstringError message for files larger than $maxSize. Supports {file} and {formattedLimit}; empty for the Yii default. Default: ''.EncodedFileValidator
$tooManystringError message for more files than $maxFiles. Supports {limit}; empty for the Yii default. Default: ''.EncodedFileValidator
$tooSmallstringError message for files smaller than $minSize. Supports {file} and {formattedLimit}; empty for the Yii default. Default: ''.EncodedFileValidator
$uploadRequiredstringError message for a required attribute without files; empty for the Yii default. Default: ''.EncodedFileValidator
$validationAttributes read-onlyarray|nullList of attribute names.yii\validators\Validator
$whencallable|nullA PHP callable whose return value determines whether this validator should be applied. Default: null.yii\validators\Validator
$whenClientstring|nullA JavaScript function name whose return value determines whether this validator should be applied on the client-side. Default: null.yii\validators\Validator
$wrongExtensionstringError message for a disallowed extension. Supports {file} and {extensions}; empty for the Yii default. Default: ''.EncodedFileValidator
$wrongMimeTypestringError message for a disallowed MIME type. Supports {file} and {mimeTypes}; empty for the Yii default. Default: ''.EncodedFileValidator
MethodDescriptionDefined by
__construct()Constructor.yii\base\BaseObject
__call()Calls the named method which is not a class method.yii\base\Component
__clone()This method is called after the object is created by cloning an existing one.yii\base\Component
__get()Returns the value of a component property.yii\base\Component
__isset()Checks if a property is set, i.e. defined and not null.yii\base\Component
__set()Sets the value of a component property.yii\base\Component
__unset()Sets a component property to be null.yii\base\Component
addError()Adds an error about the specified attribute to the model object.yii\validators\Validator
attachBehavior()Attaches a behavior to this component.yii\base\Component
attachBehaviors()Attaches a list of behaviors to the component.yii\base\Component
behaviors()Returns a list of behaviors that this component should behave as.yii\base\Component
canGetProperty()Returns a value indicating whether a property can be read.yii\base\Component
canSetProperty()Returns a value indicating whether a property can be set.yii\base\Component
className() staticReturns the fully qualified name of this class.yii\base\BaseObject
clientValidateAttribute()Returns the JavaScript needed for performing client-side validation.yii\validators\Validator
createValidator() staticCreates a validator object.yii\validators\Validator
detachBehavior()Detaches a behavior from the component.yii\base\Component
detachBehaviors()Detaches all behaviors from the component.yii\base\Component
ensureBehaviors()Makes sure that the behaviors declared in behaviors() are attached to this component.yii\base\Component
getAttributeNames()Returns cleaned attribute names without the ! character at the beginning.yii\validators\Validator
getBehavior()Returns the named behavior object.yii\base\Component
getBehaviors()Returns all behaviors attached to this component.yii\base\Component
getClientOptions()Returns the client-side validation options.yii\validators\Validator
getFormattedClientMessage()Returns the formatted validation message for client-side validation.yii\validators\Validator
getValidationAttributes()Returns a list of attributes this validator applies to.yii\validators\Validator
hasEventHandlers()Returns a value indicating whether there is any handler attached to the named event.yii\base\Component
hasMethod()Returns a value indicating whether a method is defined.yii\base\Component
hasProperty()Returns a value indicating whether a property is defined for this component.yii\base\Component
init()EncodedFileValidator
isActive()Returns a value indicating whether the validator is active for the given scenario and attribute.yii\validators\Validator
isEmpty()EncodedFileValidator
off()Detaches an existing event handler from this component.yii\base\Component
on()Attaches an event handler to an event.yii\base\Component
trigger()Triggers an event.yii\base\Component
validate()Validates a given value.yii\validators\Validator
validateAttribute()Validates a single attribute.yii\validators\Validator
validateAttributes()Validates the specified object.yii\validators\Validator
formatMessage() protectedFormats a mesage using the I18N, or simple strtr if \Yii::$app is not available.yii\validators\Validator
validateValue() protectedEncodedFileValidator
public function init(): void
public function isEmpty(mixed $value): bool

Parameters

ParameterTypeDescription
$valuemixedRequest value of the FilePond input.

Returns

bool

protected function validateValue(mixed $value): array{0: string, 1: array<string, mixed>}|null

Parameters

ParameterTypeDescription
$valuemixedRequest value of the FilePond input.

Returns

array{0: string, 1: array<string, mixed>}|null: Error message and parameters, or null when valid.