[fw-general] Zend_Validate_NotEmpty treats objects as empty values

2009-08-19 Thread Jonas Fischer
Hi,

after updating Zend Framework from version 1.8.4 to 1.9.1 I got ran
into some validation problems: In Revision 15951 the
Zend_Validate_NotEmpty validator was changed in order to fix
http://framework.zend.com/issues/browse/ZF-4352.

Now validation fails if the validated value is neither a float,
string, or integer. So objects are treated like empty values and
therefore do not pass the NotEmpty validation. However, I think
objects should be OK, too. So I locally patched my
Zend_Validate_NotEmpty validator class:


Index: tine20/library/Zend/Validate/NotEmpty.php
===
--- tine20/library/Zend/Validate/NotEmpty.php   (revision 10030)
+++ tine20/library/Zend/Validate/NotEmpty.php   (working copy)
@@ -40,7 +40,7 @@
 */
protected $_messageTemplates = array(
self::IS_EMPTY => "Value is required and can't be empty",
-self::INVALID  => "Invalid type given, value should be float,
string, or integer",
+self::INVALID  => "Invalid type given, value should be float,
string, integer or an object",
);

/**
@@ -53,7 +53,7 @@
 */
public function isValid($value)
{
-if (!is_string($value) && !is_int($value) &&
!is_float($value) && !is_bool($value)) {
+if (!is_string($value) && !is_int($value) &&
!is_float($value) && !is_bool($value) && !is_object($value)) {
$this->_error(self::INVALID);
return false;
}


What do you think? Should objects pass the NotEmpty validation?

I ran into the same problem when I tried to pass SimpleXMLElement
objects to the Zend_Validate_Digits validator. however, I agree that
this is not valid and that I have to explicitly cast my values before
validation.


Greetings!

Jonas Fischer


[fw-general] Zend_Validate_NotEmpty treats objects as empty values

2009-08-19 Thread Jonas Fischer
Hi,

after updating Zend Framework from version 1.8.4 to 1.9.1 I got ran
into some validation problems: In Revision 15951 the
Zend_Validate_NotEmpty validator was changed in order to fix
http://framework.zend.com/issues/browse/ZF-4352.

Now validation fails if the validated value is neither a float,
string, or integer. So objects are treated like empty values and
therefore do not pass the NotEmpty validation. However, I think
objects should be OK, too. So I locally patched my
Zend_Validate_NotEmpty validator class:


Index: tine20/library/Zend/Validate/NotEmpty.php
===
--- tine20/library/Zend/Validate/NotEmpty.php   (revision 10030)
+++ tine20/library/Zend/Validate/NotEmpty.php   (working copy)
@@ -40,7 +40,7 @@
  */
 protected $_messageTemplates = array(
 self::IS_EMPTY => "Value is required and can't be empty",
-self::INVALID  => "Invalid type given, value should be float,
string, or integer",
+self::INVALID  => "Invalid type given, value should be float,
string, integer or an object",
 );

 /**
@@ -53,7 +53,7 @@
  */
 public function isValid($value)
 {
-if (!is_string($value) && !is_int($value) &&
!is_float($value) && !is_bool($value)) {
+if (!is_string($value) && !is_int($value) &&
!is_float($value) && !is_bool($value) && !is_object($value)) {
 $this->_error(self::INVALID);
 return false;
 }


What do you think? Should objects pass the NotEmpty validation?


Greetings!

Jonas Fischer


[fw-general] Zend_Filter_Input: problem with presence required and null values

2009-07-20 Thread Jonas Fischer
Hi,

$validators = array(
 'requiredFieldName' => array('presence' => 'required', 'allowEmpty' => true)
)

Before Zend Framework Version 1.8.2 this validator definition worked
fine for me but in later versions it does not work with null values.

Prior to r15646 the presence of a value was checked using
array_key_exists() but now it is checked using isset().

This results in null values being recognized as not present. Is this
intended? And if so, how can I check that a field is specified (but
can be null, false, 0 etc.)?

Has anybody a solution to this problem?

Thanks in advance.


Best regards,

Jonas


[fw-general] Zend_Filter_Input: problem with presence required and null values

2009-07-20 Thread Jonas Fischer
Hi,

$validators = array(
  'requiredFieldName' => array('presence' => 'required', 'allowEmpty' => true)
)

Before Zend Framework Version 1.8.2 this validator definition worked
fine for me but in later versions it does not work with null values.

Prior to r15646 the presence of a value was checked using
array_key_exists() but now it is checked using isset().

This results in null values being recognized as not present. Is this
intended? And if so, how can I check that a field is specified (but
can be null, false, 0 etc.)?

Has anybody a solution to this problem?

Thanks in advance.


Best regards,

Jonas