Issues

ZF-212: Some extra methods for Zend_Filter

Issue Type: Improvement Created: 2006-07-09T05:03:13.000+0000 Last Updated: 2007-07-05T14:43:13.000+0000 Status: Resolved Fix version(s): - 0.9.0 (17/Mar/07)

Reporter: Oliver Saunders (irkengir) Assignee: Darby Felton (darby) Tags: - Zend_Filter

Related issues: Attachments: - testEmptyPatch.diff

Description

<pre class="highlight">
    /**
     * Test whether the length of a string is greater than a certain amount
     *
     * @param string $value
     * @param integer $length
     * @return bool
     */
    public static function testLengthGreaterThan($value, $length)
    {
        return strlen($value) > $length;
    }
    /**
     * Test whether the length of a string is less than a certain amount
     *
     * @param string $value
     * @param integer $length
     * @return bool
     */
    public static function testLengthLessThan($value, $length)
    {
        return strlen($value) < $length;
    }
    /**
     * Test whether the key is empty. 
     * 
     * @param string $value
     * @return bool
     */
    public function testEmpty($value)
    {
        return empty($value);
    }

Comments

Posted by Mark Evans (sparky) on 2006-07-09T10:12:37.000+0000

I think these are a good suggestion..

I will get a patch organised.

Posted by Oliver Saunders (irkengir) on 2006-07-09T10:18:28.000+0000

Great thank you.

Just realised the testLengthLessThan() and testLengthGreaterThan() functions should have an $inclusive argument to conform with existing testGreaterThan() and testLessThan()

Posted by Jon Whitcraft (sidhighwind) on 2006-10-16T22:37:24.000+0000

What is the status of this patch? Do you think that it will make it into the 0.1.6 release?

Posted by Jon Whitcraft (sidhighwind) on 2006-10-23T18:23:20.000+0000

This is a patch to have the filter object has a testEmpty in the Zend_Filter_Input Class and a isEmpty function in the Zend_Filter Class.

Posted by Jon Whitcraft (sidhighwind) on 2006-10-23T22:51:35.000+0000

Ok so i am sorry about my first patch submitted but it doesnt work correctly. after doing more testing i found a quick bug in it that i am currently fixing. I will post a new one once i'm sure it works across the board. I didnt see a way to delete or mark a file a out dated.

Posted by Bill Karwin (bkarwin) on 2006-11-13T15:23:35.000+0000

Changing fix version to 0.9.0.

Posted by Waldemar Schott (wschott) on 2006-11-15T12:45:56.000+0000

In my opinion the testEmpty() and isEmpty() methods are completeley unnecessary. In fact it's a oneliner.

Posted by Jon Whitcraft (sidhighwind) on 2006-11-19T13:42:00.000+0000

I don't see them as being unnecessary as right now to test is something is empty you would have to set it to a variable then test the variable to see if it's empty, which makes it two lines not one.

This code will not work as it generates a parse error.

<pre class="highlight">
if(empty($name = $filterList->getRaw('an_name'))) {

I see a value in having a testEmpty function as then you can easily test to see if it's empty in one line instead of setting it to a variable and then testing that variable.

Posted by Darby Felton (darby) on 2007-03-16T12:18:16.000+0000

Zend_Filter no longer uses static methods for filtering. Instead, Zend_Validate_StringLength may be used for the string length testing purposes.

If the need remains for an "isEmpty" validation class, please feel free to formalize the suggestion by writing a proposal that covers the use cases and solution details.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts