Yii Framework 3.0 API Documentation
This is the Yii Framework API Documentation. Here you will find detailed information about all classes provided by the Framework. Below you find a list of the existing classes, interfaces, and traits, ordered by their fully qualified name (including the namespace). Each of them has a dedicated page which contains a description about the purpose of the class, a list of the available methods, properties and constants, and detailed description on how to use each of them.
On this page you find all the classes included in version 3.0 of the framework. You can use the dropdown menu on the top right to switch between versions.
You can search API documentation using the search form on the top.
You can search for class names and also method and property names, e.g. ActiveRecord.save() or just .save() or ::save().
This page is also available in JSON format:curl https://www.yiiframework.com/doc/api/3.0/validator -H 'Accept: application/json'
| Class | Description |
|---|---|
| Yiisoft\Validator\AfterInitAttributeEventInterface | An optional interface for rules to implement. It provides {@see afterInitAttribute()} method-based event allowing to execute custom code after a rule instance was created from a PHP attribute either when using {@see ObjectDataSet}, {@see AttributesRulesProvider} or {@see ObjectParser} directly. |
| Yiisoft\Validator\CountableLimitInterface | An optional interface for rules to implement. Rules implementing it must have minimum and maximum limits and also "exactly" value for strict equality. Boundaries must reflect numbers of countable items. |
| Yiisoft\Validator\DataSetInterface | An interface for unifying access to different types of validated data. A class implementing it is called "data set". |
| Yiisoft\Validator\DataSet\ArrayDataSet | A data set for storing data as an associative array, where keys are property names and values are their corresponding values. An example of usage: |
| Yiisoft\Validator\DataSet\ObjectDataSet | A data set for object data. The object passed to this data set can provide rules and data by implementing {@see RulesProviderInterface} and {@see DataSetInterface}. Alternatively this data set allows getting rules from PHP attributes (attached to class properties and class itself) and data from object properties. |
| Yiisoft\Validator\DataSet\SingleValueDataSet | A data set used for a single value of any (mixed) data type. Does not support PHP attributes. |
| Yiisoft\Validator\DataWrapperInterface | Data wrapper interface provides access to raw data behind a data set. |
| Yiisoft\Validator\Debug\ValidatorCollector | |
| Yiisoft\Validator\Debug\ValidatorInterfaceProxy | |
| Yiisoft\Validator\DumpedRuleInterface | An extended version of {@see RuleInterface} which allows exporting a rule options and name customization. It's useful for passing to frontend for further identification and implementing client-side validation. If you don't need that (for example for REST API), use {@see RuleInterface} instead. |
| Yiisoft\Validator\EmptyCondition\NeverEmpty | Empty condition is a callable returning true if a value must be considered empty. |
| Yiisoft\Validator\EmptyCondition\WhenEmpty | Empty condition is a callable returning true if a value must be considered empty. |
| Yiisoft\Validator\EmptyCondition\WhenMissing | Empty condition is a callable returning true if a value must be considered empty. |
| Yiisoft\Validator\EmptyCondition\WhenNull | Empty condition is a callable returning true if a value must be considered empty. |
| Yiisoft\Validator\Error | A class representing validation error. It's added in a rule handler or via {@see Callback} rule to the {@see Result} to form the complete list of errors for a single validation. |
| Yiisoft\Validator\Exception\InvalidCallbackReturnTypeException | An exception used by the handler ({@see CallbackHandler}) of {@see Callback} rule for the cases when returned value is not a {@see Result} instance. |
| Yiisoft\Validator\Exception\RuleHandlerInterfaceNotImplementedException | An exception used by {@see RuleHandlerResolverInterface} implementations (e. g., {@see RuleHandlerContainer}) for the case when a retrieved value is not an object or an object that does not implement {@see RuleHandlerInterface}. |
| Yiisoft\Validator\Exception\RuleHandlerNotFoundException | An exception used by {@see RuleHandlerContainer} for the case when a given class name was not found in the container. |
| Yiisoft\Validator\Exception\UnexpectedRuleException | An exception used by rule handlers to guarantee that passed rule have desired type. Every handler's validation code
must start with this check. An example for MyRule and MyRuleHandler: |
| Yiisoft\Validator\Helper\DataSetNormalizer | A helper class used to normalize different types of validated data to a data set ({@see DataSetInterface}). |
| Yiisoft\Validator\Helper\MessageProcessor | |
| Yiisoft\Validator\Helper\ObjectParser | A helper class used to parse rules from PHP attributes (attached to class properties and class itself) and data from object properties. The attributes introduced in PHP 8 simplify rules' configuration process, especially for nested data and relations. This way the validated structures can be presented as DTO classes with references to each other. |
| Yiisoft\Validator\Helper\PropagateOptionsHelper | A helper class used to propagate options' values from a single parent rule to its child rules at all nesting levels recursively. |
| Yiisoft\Validator\Helper\RulesDumper | RulesDumper allows to get an array of rule names and corresponding settings from a set of rules. |
| Yiisoft\Validator\Helper\RulesNormalizer | A helper class used to normalize different types of data to the iterable with rule instances ({@see RuleInterface}). |
| Yiisoft\Validator\Helper\RulesNormalizerIterator | An iterator for a set of rules, performs normalization for every individual rule unifying other provided types and verifying that every item is a valid rule instance. It also applies some default settings if needed. |
| Yiisoft\Validator\Helper\SkipOnEmptyNormalizer | A helper class used to normalize different types of "skip on empty" values including shortcuts to a callable ({@see SkipOnEmptyInterface}). |
| Yiisoft\Validator\Label | |
| Yiisoft\Validator\LabelsProviderInterface | Provides data property labels. |
| Yiisoft\Validator\PostValidationHookInterface | An optional interface for validated objects to implement. It provides {@see processValidationResult()} method-based hook allowing to execute custom code after a validation {@see Result} has been formed. |
| Yiisoft\Validator\PropagateOptionsInterface | An optional interface for rules to implement. Allows to propagate their common options' values to child rules as an alternative way of specifying them explicitly in every child rule. |
| Yiisoft\Validator\PropertyTranslatorInterface | Allows translating property names. |
| Yiisoft\Validator\PropertyTranslatorProviderInterface | Provides optional implementation of {@see PropertyTranslatorInterface} for translation of property names. |
| Yiisoft\Validator\PropertyTranslator\ArrayPropertyTranslator | A property translator that uses array of translations. |
| Yiisoft\Validator\PropertyTranslator\NullPropertyTranslator | A property translator that returns property name as is without actually translating it. |
| Yiisoft\Validator\PropertyTranslator\TranslatorPropertyTranslator | A property translator that uses {@see TranslatorInterface}. |
| Yiisoft\Validator\Result | Validation result that is used by both {@see ValidatorInterface} and {@see RuleHandlerInterface}. |
| Yiisoft\Validator\RuleHandlerInterface | An interface for rule handlers to implement. While a rule contains a set of constraint configuration options, a handler performs an actual validation using them against a provided value. Every rule has only one matching rule handler. |
| Yiisoft\Validator\RuleHandlerResolverInterface | An interface allowing to resolve a rule handler name to a corresponding rule handler instance. |
| Yiisoft\Validator\RuleHandlerResolver\RuleHandlerContainer | An implementation for {@see RuleHandlerResolverInterface} acting as a wrapper over dependency injection container ({@see ContainerInterface}) throwing more specific exceptions and executing additional checks during resolving a rule handler name to make sure that if a handler was found, then it's indeed a valid handler to work with. |
| Yiisoft\Validator\RuleHandlerResolver\SimpleRuleHandlerContainer | An implementation for {@see RuleHandlerResolverInterface} using internal class instance variable as a storage of rule handlers' instances. Use it if you don't need PSR container ({@see ContainerInterface}), otherwise {@see RuleHandlerContainer} can be used instead. It's enabled by default to you don't need to additionally configure anything. |
| Yiisoft\Validator\RuleInterface | A main interface for rules to implement. A rule contains a set of constraint configuration options to apply when validating data. If you want to include a rule options and customize its name during conversion to array, use extended version of it - {@see DumpedRuleInterface}. |
| Yiisoft\Validator\Rule\AbstractCompare | Abstract base for all the comparison validation rules. |
| Yiisoft\Validator\Rule\AbstractNumber | Defines validation options to check that the value is a number. |
| Yiisoft\Validator\Rule\AnyRule | Applies to a set of rules, runs validation for each one of them in the order they are defined and stops at the rule where validation passed. The opposite of {@see StopOnError}. |
| Yiisoft\Validator\Rule\AnyRuleHandler | A handler for {@see AnyRule} rule. Validates a set of rules consecutively and stops at the rule where validation has passed. |
| Yiisoft\Validator\Rule\BooleanValue | Contains a set of options to determine if the value is "true" or "false", not limited to boolean type only. What values exactly are considered "true" and "false" can be configured via {@see BooleanValue::$trueValue} and {@see BooleanValue::$falseValue} settings accordingly. There is also an option to choose between strict and non-strict mode of comparison (see {@see BooleanValue::$strict}). |
| Yiisoft\Validator\Rule\BooleanValueHandler | A handler for {@see BooleanValue} rule. |
| Yiisoft\Validator\Rule\Callback | Defines validation options to validating the value using a callback. |
| Yiisoft\Validator\Rule\CallbackHandler | Validates a value using a callback. |
| Yiisoft\Validator\Rule\Compare | Defines validation options to compare the specified value with "target" value provided directly ({@see GreaterThanOrEqual::$targetValue}) or within a property ({@see GreaterThanOrEqual::$targetProperty}). |
| Yiisoft\Validator\Rule\CompareHandler | Compares the specified value with "target" value provided directly or within a property. |
| Yiisoft\Validator\Rule\CompareType | Enum for {@see AbstractCompare::$type}. |
| Yiisoft\Validator\Rule\Composite | Allows to group multiple rules for validation. It's helpful when skipOnEmpty, skipOnError or when options are
the same for every rule in the set. |
| Yiisoft\Validator\Rule\CompositeHandler | A handler for {@see Composite} handler. Validates group of rules. |
| Yiisoft\Validator\Rule\Count | Defines validation options to check that the value contains certain number of items. |
| Yiisoft\Validator\Rule\CountHandler | Validates that the value contains certain number of items. |
| Yiisoft\Validator\Rule\Date\BaseDate | |
| Yiisoft\Validator\Rule\Date\BaseDateHandler | |
| Yiisoft\Validator\Rule\Date\Date | Defines validation options to check that the value is a date. |
| Yiisoft\Validator\Rule\Date\DateHandler | |
| Yiisoft\Validator\Rule\Date\DateTime | Defines validation options to check that the value is a date with time. |
| Yiisoft\Validator\Rule\Date\DateTimeHandler | |
| Yiisoft\Validator\Rule\Date\Time | Defines validation options to check that the value is a time. |
| Yiisoft\Validator\Rule\Date\TimeHandler | |
| Yiisoft\Validator\Rule\Each | Allows to define a set of rules for validating each element of an iterable. |
| Yiisoft\Validator\Rule\EachHandler | A handler for {@see Each} rule. Validates each element of an iterable using a set of rules. |
| Yiisoft\Validator\Rule\Email | Defines validation options to check that the value is a valid email address. |
| Yiisoft\Validator\Rule\EmailHandler | Validates that the value is a valid email address. |
| Yiisoft\Validator\Rule\Equal | Defines validation options to check that the specified value is equal to "target" value provided directly ({@see Equal::$targetValue}) or within a property ({@see Equal::$targetProperty}). |
| Yiisoft\Validator\Rule\FilledAtLeast | Defines validation options to check that a minimum number of specified properties are filled. |
| Yiisoft\Validator\Rule\FilledAtLeastHandler | Validates that a minimum number of specified properties are filled. |
| Yiisoft\Validator\Rule\FilledOnlyOneOf | Defines validation options to check that only one of specified properties is filled. |
| Yiisoft\Validator\Rule\FilledOnlyOneOfHandler | Validates that only one of specified properties is filled. |
| Yiisoft\Validator\Rule\GreaterThan | Defines validation options to check that the specified value is equal to "target" value provided directly ({@see GreaterThan::$targetValue}) or within an property ({@see GreaterThan::$targetProperty}). |
| Yiisoft\Validator\Rule\GreaterThanOrEqual | Defines validation options to check that the specified value is equal to "target" value provided directly ({@see GreaterThanOrEqual::$targetValue}) or within a property ({@see GreaterThanOrEqual::$targetProperty}). |
| Yiisoft\Validator\Rule\Image\CompositeImageInfoProvider | |
| Yiisoft\Validator\Rule\Image\Image | Defines validation options to check that a value is an image and optionally check its dimensions. |
| Yiisoft\Validator\Rule\Image\ImageAspectRatio | |
| Yiisoft\Validator\Rule\Image\ImageHandler | Validates that a value is an image and optionally checks its dimensions. |
| Yiisoft\Validator\Rule\Image\ImageInfo | |
| Yiisoft\Validator\Rule\Image\ImageInfoProviderInterface | |
| Yiisoft\Validator\Rule\Image\NativeImageInfoProvider | > PHP native function getimagesize() don't support HEIF / HEIC formats. |
| Yiisoft\Validator\Rule\In | Defines validation options to check that the value is one of the values provided in {@see $values}. |
| Yiisoft\Validator\Rule\InEnum | Defines validation options to check that the value is one of the values (or names) contained in an enum of the specified class. |
| Yiisoft\Validator\Rule\InEnumHandler | Validates that the value is one of the values of a specified enum. |
| Yiisoft\Validator\Rule\InHandler | Validates that the value is one of the values provided. |
| Yiisoft\Validator\Rule\Integer | Defines validation options to check that the value is an integer number. |
| Yiisoft\Validator\Rule\Ip | Checks if the value is a valid IPv4/IPv6 address or subnet. |
| Yiisoft\Validator\Rule\IpHandler | Checks if the value is a valid IPv4/IPv6 address or subnet. |
| Yiisoft\Validator\Rule\Json | Contains a set of options to determine if the value is a valid JSON string. |
| Yiisoft\Validator\Rule\JsonHandler | A handler for {@see Json} rule. Validates that the value is a valid JSON string. |
| Yiisoft\Validator\Rule\Length | Defines validation options to check that the value is a string of a certain length. |
| Yiisoft\Validator\Rule\LengthHandler | Validates that the value is a string of a certain length. |
| Yiisoft\Validator\Rule\LessThan | Defines validation options to check that the specified value is equal to "target" value provided directly ({@see LessThan::$targetValue}) or within a property ({@see LessThan::$targetProperty}). |
| Yiisoft\Validator\Rule\LessThanOrEqual | Defines validation options to check that the specified value is equal to "target" value provided directly ({@see LessThanOrEqual::$targetValue}) or within a property ({@see LessThanOrEqual::$targetProperty}). |
| Yiisoft\Validator\Rule\Nested | Used to define rules for validation of nested structures: |
| Yiisoft\Validator\Rule\NestedHandler | A handler for {@see Nested} rule. Validates nested structures. |
| Yiisoft\Validator\Rule\NotEqual | Defines validation options to check that the specified value is equal to "target" value provided directly ({@see NotEqual::$targetValue}) or within a property ({@see NotEqual::$targetProperty}). |
| Yiisoft\Validator\Rule\Number | Defines validation options to check that the value is a number. |
| Yiisoft\Validator\Rule\NumberHandler | Validates that the value is a number. |
| Yiisoft\Validator\Rule\Regex | Defines validation options to check that the value matches the pattern specified in constructor. |
| Yiisoft\Validator\Rule\RegexHandler | Validates that the value matches the pattern specified in constructor. |
| Yiisoft\Validator\Rule\Required | Contains a set of options to determine if the value is not empty according to {@see Required::$emptyCondition}. When rule-level condition is not set, a handler-level condition ({@see RequiredHandler::$defaultEmptyCondition}) is applied (which is also customizable). In case of using attributes, the property must be present with passed non-empty value. |
| Yiisoft\Validator\Rule\RequiredHandler | A handler for {@see Required} rule. Validates that the specified value is passed and is not empty. |
| Yiisoft\Validator\Rule\StopOnError | Applies to a set of rules, runs validation for each one of them in the order they are defined and stops at the rule where validation failed. |
| Yiisoft\Validator\Rule\StopOnErrorHandler | A handler for {@see StopOnError} rule. Validates a set of rules consecutively and stops at the rule where validation has failed. |
| Yiisoft\Validator\Rule\StringValue | Defines validation options to check that the value is a string. |
| Yiisoft\Validator\Rule\StringValueHandler | Validates that the value is a string. |
| Yiisoft\Validator\Rule\Subset | A variation of {@see In} rule allowing to use the set of values instead of single value as an input for checking if it's a subset of the set provided in {@see Subset::$values}. |
| Yiisoft\Validator\Rule\SubsetHandler | A handler for {@see Subset} rule. Validates that the set of values is a subset of another set. |
| Yiisoft\Validator\Rule\Trait\CountableLimitHandlerTrait | A trait attachable to a handler of rule with limits. Requires a rule to implement {@LimitInterface} / include {@see CountableLimitTrait}. |
| Yiisoft\Validator\Rule\Trait\CountableLimitTrait | An implementation for {@see CountableLimitInterface} intended to be included in rules. The following arguments need to be added in constructor and passed with {@see initLimitProperties()} call: |
| Yiisoft\Validator\Rule\Trait\SkipOnEmptyTrait | An implementation for {@see SkipOnEmptyInterface} intended to be included in rules. Requires an additional private
class property $skipOnEmpty. In package rules it's null by default: |
| Yiisoft\Validator\Rule\Trait\SkipOnErrorTrait | An implementation for {@see SkipOnErrorInterface} intended to be included in rules. Requires an additional private
class property $skipOnError. In package rules it's false by default: |
| Yiisoft\Validator\Rule\Trait\TranslatedPropertiesHandlerTrait | |
| Yiisoft\Validator\Rule\Trait\WhenTrait | An implementation for {@see WhenInterface} intended to be included in rules. Requires an additional private class
property $when. In package rules it's null by default: |
| Yiisoft\Validator\Rule\TrueValue | A variation of {@see BooleanValue} rule limiting the allowed values to "true" only (not limited to boolean "true" type). What value exactly is considered "true" can be configured via {@see TrueValue::$trueValue} setting. There is also an option to choose between strict and non-strict mode of comparison (see {@see TrueValue::$strict}). |
| Yiisoft\Validator\Rule\TrueValueHandler | A handler for {@see TrueValue} rule. |
| Yiisoft\Validator\Rule\Type\BooleanType | Defines validation options to check that the value has boolean type. It's different from {@see BooleanValue} because it only strictly allows boolean values ({@link https://www.php.net/manual/en/language.types.boolean.php}) and not the ones that evaluates to boolean ("truthy" / "falsy"). If you need to support that, consider to use {@see BooleanValue} instead. |
| Yiisoft\Validator\Rule\Type\BooleanTypeHandler | A handler for {@see BooleanType} rule. Validates that the value has a boolean type (strictly) - {@link https://www.php.net/manual/en/language.types.boolean.php}. |
| Yiisoft\Validator\Rule\Type\FloatType | Defines validation options to check that the value has float type. Only native PHP float type - {@link https://www.php.net/manual/en/language.types.float.php} is allowed. For example, the float number within a string is discarded. If you need to support that, consider to use {@see Number} instead. |
| Yiisoft\Validator\Rule\Type\FloatTypeHandler | A handler for {@see FloatType} rule. Validates that the value has float type - {@link https://www.php.net/manual/en/language.types.float.php}. |
| Yiisoft\Validator\Rule\Type\IntegerType | Defines validation options to check that the value has integer type. Only native PHP integer type - {@link https://www.php.net/manual/en/language.types.integer.php} is allowed. For example, the integer number within a string is discarded. If you need to support that, consider to use {@see Integer} instead. |
| Yiisoft\Validator\Rule\Type\IntegerTypeHandler | A handler for {@see IntegerType} rule. Validates that the value has integer type - {@link https://www.php.net/manual/en/language.types.integer.php}. |
| Yiisoft\Validator\Rule\Type\StringType | Defines validation options to check that the value has string type. Only native PHP string type - {@link https://www.php.net/manual/en/language.types.string.php} is allowed. |
| Yiisoft\Validator\Rule\Type\StringTypeHandler | A handler for {@see StringType} rule. Validates that the value has string type - {@link https://www.php.net/manual/en/language.types.string.php}. |
| Yiisoft\Validator\Rule\UniqueIterable | Allows to define a set of rules for validating uniqueness of each element of an iterable. |
| Yiisoft\Validator\Rule\UniqueIterableHandler | A handler for {@see UniqueIterable} rule. Validates uniqueness of each element of an iterable. |
| Yiisoft\Validator\Rule\Url | Defines validation options for a value that is a valid HTTP or HTTPS URL. |
| Yiisoft\Validator\Rule\UrlHandler | Validates that the value is a valid HTTP or HTTPS URL. |
| Yiisoft\Validator\Rule\Uuid | Checks if the value is a valid UUID. |
| Yiisoft\Validator\Rule\UuidHandler | Validates that a value is a proper UUID string. |
| Yiisoft\Validator\RulesProviderInterface | Provides data validation rules. |
| Yiisoft\Validator\RulesProvider\AttributesRulesProvider | A rules provider that extracts rules from PHP attributes (attached to class properties and class itself). The attributes introduced in PHP 8 simplify rules' configuration process, especially for nested data and relations. This way the validated structures can be presented as DTO classes with references to each other. |
| Yiisoft\Validator\SkipOnEmptyInterface | An optional interface for rules to implement. It allows skipping validation for a rule when the validated value is "empty". |
| Yiisoft\Validator\SkipOnErrorInterface | An optional interface for rules to implement. It allows skipping validation for a rule within a group of other rules if a previous rule (not the current one!) did not pass the validation. |
| Yiisoft\Validator\ValidationContext | Validation context that might be taken into account when performing validation. |
| Yiisoft\Validator\Validator | The only built-in implementation of {@see ValidatorInterface}, the main class / entry point processing all the data and rules with validation context together and performing the actual validation. |
| Yiisoft\Validator\ValidatorInterface | An interface allowing to validate the data according to the set of rules ({@see RuleInterface}) and validation context ({@see ValidationContext}). A class implementing it is called "validator". |
| Yiisoft\Validator\WhenInterface | An optional interface for rules to implement. It allows applying validation for a rule within a group of other rules under certain conditions. |
Signup or Login in order to comment.