Hi All,

I'm using NotEmpty validator with the new Zend_Form component, to
validate empty fields. But it didn't work out as expected because it
doesn't consider a '0' (zero string) to be empty.

Use cases:

  1. Validating numbers, which could have 0 as perfectly valid input.
  2. Validating input of radio options that have one of their items'
value set to 0. Example: array(1 => 'Yes', 0 => 'No'). Or similar
controls like select lists.

I understand that this is due to PHP's empty() but I was also
wondering if it's worth adding a special case for string '0'. Of
course, I'm proposing adding strict type checking only, so the integer
0 would still give a false. But string '0' would give a true. The end
behavior would make more sense IMHO.

Thank you

Best,
- Amr

Reply via email to