ZF-12057: Zend_Validate_Ldap_Dn

Description

I'm using a Zend_Form to configure an LDAP server and i noticed that Zend does not provide any validator for DN, so i created a simple validator that uses the Zend_Ldap_Dn::checkDn method. Here's what i got:


class Zend_Validate_Ldap_Dn extends Zend_Validate_Abstract
{

    const MALFORMED = 'malformed';
    
    /**
     * Validation failure message template definitions.
     *
     * @var array
     */
    protected $_messageTemplates = array(
        self::MALFORMED => 'DN is malformed',
    );
    
    /**
     * Defined by Zend_Validate_Interface.
     *
     * Returns true if and only if $value is a valid DN.
     *
     * @param string $value The value to be validated.
     * 
     * @return boolean
     */
    public function isValid($value) 
    {
        $valid = Zend_Ldap_Dn::checkDn($value);
        if ($valid === false) {
            $this->_error(self::MALFORMED);
            return false;
        }
        return true;
    }
}

Comments

Fixed in svn r24956