Asking for a php countable interface should be sufficient. I think it's safe to 
say any container object containig 0 contained objects is empty. No ? php 
empty() does that with arrays (but not with countable objects).

Ludwig


From: Hector Virgen 
Sent: Thursday, March 04, 2010 7:21 PM
To: Maghiel Dijksman 
Cc: fw-general@lists.zend.com 
Subject: Re: [fw-general] Zend_Validate_NotEmpty and Object


One such "empty" object would be an iterator that has nothing to iterate. There 
are other examples, but there's no way to test if an object is empty without a 
method to determine it because various objects would have different 
implementations on how to determine if it is empty.

--
Hector



On Thu, Mar 4, 2010 at 10:17 AM, Maghiel Dijksman <m...@mdijksman.nl> wrote:

  How can an object be empty? It's an instance of a class. So it is something. 


  On 4-3-2010 17:55, Alayn Gortazar wrote:

    El jue, 04-03-2010 a las 08:32 -0800, Hector Virgen escribió:
      

      You could create an "Empty" interface (or rather, Emptiable since I
      don't think you can use Empty):


      interface Emptiable
      {
          public function isEmpty();
      }


      Then make your validator accept Emptiable objects along with strings,
      arrays, ints, etc.


      Maybe you can come up with a better name than Emptiable :)
          

    Yep you can always extend NotEmpty validator and add particular cases.

    I was just wondering if Zend really needed such a "feature", don't
    really think so.

    Thanks anyway, ;)


      



Reply via email to