Class Validator
Definition at line 11 of file Validator.php.
◆ __construct()
◆ _instantiateValidators()
_instantiateValidators |
( |
array & |
$validators | ) |
|
|
protected |
Instantiate class validator
- Parameters
-
- Returns
- $this
Definition at line 132 of file Validator.php.
134 foreach ($validators as &$validator) {
135 if (is_string($validator[
'class'])) {
136 $validator[
'class'] =
new $validator[
'class']($validator[
'options']);
137 $validator[
'class']->setDisableTranslator(
true);
◆ _setTitleValidators()
Set title validators
- Returns
- $this
Definition at line 43 of file Validator.php.
47 'name' =>
'not_empty',
48 'class' =>
'Zend_Validate_NotEmpty',
51 'message' => (string)
new \
Magento\Framework\Phrase(
'Field title can\'t be empty'),
addDataValidators($dataKey, $validators)
◆ _setTypeValidators()
Set theme type validators
- Returns
- $this
Definition at line 64 of file Validator.php.
68 'name' =>
'not_empty',
69 'class' =>
'Zend_Validate_NotEmpty',
72 'message' => (string)
new \
Magento\Framework\Phrase(
'Theme type can\'t be empty'),
75 'name' =>
'available',
76 'class' =>
'Zend_Validate_InArray',
85 'message' => (string)
new \
Magento\Framework\Phrase(
'Theme type is invalid')
addDataValidators($dataKey, $validators)
◆ _validateDataItem()
_validateDataItem |
( |
|
$validator, |
|
|
|
$dataKey, |
|
|
|
$dataValue |
|
) |
| |
|
protected |
Validate one data item
- Parameters
-
array | $validator | |
string | $dataKey | |
mixed | $dataValue | |
- Returns
- bool
Definition at line 151 of file Validator.php.
155 ) || !empty($dataValue) && !$validator[
'class']->isValid(
159 $this->_errorMessages[$dataKey][] = $validator[
'message'];
160 if ($validator[
'break']) {
◆ addDataValidators()
addDataValidators |
( |
|
$dataKey, |
|
|
|
$validators |
|
) |
| |
Add validators
- Parameters
-
string | $dataKey | |
array | $validators | |
- Returns
- $this
Definition at line 101 of file Validator.php.
103 if (!isset($this->_dataValidators[$dataKey])) {
104 $this->_dataValidators[$dataKey] = [];
106 foreach ($validators as $validator) {
107 $this->_dataValidators[$dataKey][$validator[
'name']] = $validator;
◆ getErrorMessages()
getErrorMessages |
( |
|
$dataKey = null | ) |
|
Return error messages for items
- Parameters
-
- Returns
- array
Definition at line 118 of file Validator.php.
121 return $this->_errorMessages[$dataKey] ?? [];
◆ validate()
Validate all data items
- Parameters
-
\Magento\Framework\DataObject | $data | |
- Returns
- bool
Definition at line 173 of file Validator.php.
175 $this->_errorMessages = [];
176 foreach ($this->_dataValidators as $dataKey => $validators) {
177 if (!isset(
$data[$dataKey])) {
182 foreach ($validators as $validator) {
188 return empty($this->_errorMessages);
_validateDataItem($validator, $dataKey, $dataValue)
_instantiateValidators(array &$validators)
◆ $_dataValidators
◆ $_errorMessages
The documentation for this class was generated from the following file: