|
@@ -740,19 +740,21 @@ class Zend_Filter_Input
|
|
|
if (!isset($validatorRule[self::ALLOW_EMPTY])) {
|
|
if (!isset($validatorRule[self::ALLOW_EMPTY])) {
|
|
|
$validatorRule[self::ALLOW_EMPTY] = $this->_defaults[self::ALLOW_EMPTY];
|
|
$validatorRule[self::ALLOW_EMPTY] = $this->_defaults[self::ALLOW_EMPTY];
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
if (!isset($validatorRule[self::MESSAGES])) {
|
|
if (!isset($validatorRule[self::MESSAGES])) {
|
|
|
$validatorRule[self::MESSAGES] = array();
|
|
$validatorRule[self::MESSAGES] = array();
|
|
|
} else if (!is_array($validatorRule[self::MESSAGES])) {
|
|
} else if (!is_array($validatorRule[self::MESSAGES])) {
|
|
|
$validatorRule[self::MESSAGES] = array($validatorRule[self::MESSAGES]);
|
|
$validatorRule[self::MESSAGES] = array($validatorRule[self::MESSAGES]);
|
|
|
- } else if (!array_intersect_key($validatorList, $validatorRule[self::MESSAGES])) {
|
|
|
|
|
|
|
+ } else if (array_intersect_key($validatorList, $validatorRule[self::MESSAGES])) {
|
|
|
// There are now corresponding numeric keys in the validation rule messages array
|
|
// There are now corresponding numeric keys in the validation rule messages array
|
|
|
// Treat it as a named messages list for all rule validators
|
|
// Treat it as a named messages list for all rule validators
|
|
|
- /** @todo Update documentation to describe this possibility */
|
|
|
|
|
$unifiedMessages = $validatorRule[self::MESSAGES];
|
|
$unifiedMessages = $validatorRule[self::MESSAGES];
|
|
|
$validatorRule[self::MESSAGES] = array();
|
|
$validatorRule[self::MESSAGES] = array();
|
|
|
|
|
|
|
|
foreach ($validatorList as $key => $validator) {
|
|
foreach ($validatorList as $key => $validator) {
|
|
|
- $validatorRule[self::MESSAGES][$key] = $unifiedMessages;
|
|
|
|
|
|
|
+ if (array_key_exists($key, $unifiedMessages)) {
|
|
|
|
|
+ $validatorRule[self::MESSAGES][$key] = $unifiedMessages[$key];
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -766,6 +768,7 @@ class Zend_Filter_Input
|
|
|
if (is_string($validator) || is_array($validator)) {
|
|
if (is_string($validator) || is_array($validator)) {
|
|
|
$validator = $this->_getValidator($validator);
|
|
$validator = $this->_getValidator($validator);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
if (isset($validatorRule[self::MESSAGES][$key])) {
|
|
if (isset($validatorRule[self::MESSAGES][$key])) {
|
|
|
$value = $validatorRule[self::MESSAGES][$key];
|
|
$value = $validatorRule[self::MESSAGES][$key];
|
|
|
if (is_array($value)) {
|
|
if (is_array($value)) {
|
|
@@ -773,6 +776,10 @@ class Zend_Filter_Input
|
|
|
} else {
|
|
} else {
|
|
|
$validator->setMessage($value);
|
|
$validator->setMessage($value);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ if ($validator instanceof Zend_Validate_NotEmpty) {
|
|
|
|
|
+ $this->_defaults[self::NOT_EMPTY_MESSAGE] = $value;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$validatorRule[self::VALIDATOR_CHAIN]->addValidator($validator, $validatorRule[self::BREAK_CHAIN]);
|
|
$validatorRule[self::VALIDATOR_CHAIN]->addValidator($validator, $validatorRule[self::BREAK_CHAIN]);
|
|
@@ -882,12 +889,14 @@ class Zend_Filter_Input
|
|
|
$emptyFieldsFound = true;
|
|
$emptyFieldsFound = true;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
if ($emptyFieldsFound) {
|
|
if ($emptyFieldsFound) {
|
|
|
$this->_invalidMessages[$validatorRule[self::RULE]] = $messages;
|
|
$this->_invalidMessages[$validatorRule[self::RULE]] = $messages;
|
|
|
$this->_invalidErrors[$validatorRule[self::RULE]] = array_unique(call_user_func_array('array_merge', $errorsList));
|
|
$this->_invalidErrors[$validatorRule[self::RULE]] = array_unique(call_user_func_array('array_merge', $errorsList));
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
if (!$validatorRule[self::VALIDATOR_CHAIN]->isValid($data)) {
|
|
if (!$validatorRule[self::VALIDATOR_CHAIN]->isValid($data)) {
|
|
|
$this->_invalidMessages[$validatorRule[self::RULE]] = $validatorRule[self::VALIDATOR_CHAIN]->getMessages();
|
|
$this->_invalidMessages[$validatorRule[self::RULE]] = $validatorRule[self::VALIDATOR_CHAIN]->getMessages();
|
|
|
$this->_invalidErrors[$validatorRule[self::RULE]] = $validatorRule[self::VALIDATOR_CHAIN]->getErrors();
|
|
$this->_invalidErrors[$validatorRule[self::RULE]] = $validatorRule[self::VALIDATOR_CHAIN]->getErrors();
|
|
@@ -899,13 +908,11 @@ class Zend_Filter_Input
|
|
|
$fieldName = reset($fieldNames);
|
|
$fieldName = reset($fieldNames);
|
|
|
$field = reset($data);
|
|
$field = reset($data);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
$failed = false;
|
|
$failed = false;
|
|
|
if (!is_array($field)) {
|
|
if (!is_array($field)) {
|
|
|
$field = array($field);
|
|
$field = array($field);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
$notEmptyValidator = $this->_getValidator('NotEmpty');
|
|
$notEmptyValidator = $this->_getValidator('NotEmpty');
|
|
|
$notEmptyValidator->setMessage($this->_getNotEmptyMessage($validatorRule[self::RULE], $fieldName));
|
|
$notEmptyValidator->setMessage($this->_getNotEmptyMessage($validatorRule[self::RULE], $fieldName));
|
|
|
if ($validatorRule[self::ALLOW_EMPTY]) {
|
|
if ($validatorRule[self::ALLOW_EMPTY]) {
|