首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >zend-form中的验证

zend-form中的验证
EN

Stack Overflow用户
提问于 2012-08-14 14:13:29
回答 1查看 121关注 0票数 0

当使用更改密码在Zend中,我想检查旧密码和新的password.Both不应该是same.Is在Zend中有任何选项来检查这两个。

提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2012-08-14 14:31:35

在My下创建一个库,并使用以下内容:

代码语言:javascript
复制
class My_Validate_PasswordConfirmation extends Zend_Validate_Abstract
{
    const NOT_MATCH = 'notMatch';
 
    protected $_messageTemplates = array(
        self::NOT_MATCH => 'Password confirmation does not match'
    );
 
    public function isValid($value, $context = null)
    {
        $value = (string) $value;
        $this->_setValue($value);
 
        if (is_array($context)) {
            if (isset($context['password_confirm'])
                && ($value == $context['password_confirm']))
            {
                return true;
            }
        } elseif (is_string($context) && ($value == $context)) {
            return true;
        }
 
        $this->_error(self::NOT_MATCH);
        return false;
    }
}

More Information at the : Zend Manual向下滚动到或查找:

注释:验证上下文

在源页面上。代码就在它的下方,解释也是如此。

希望它能有所帮助!:)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11946703

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档