星期五, 3月 18, 2011

Zend validator

  • validator
    $validator = new Zend_Validate_NotEmpty();
    if($validator->isValid($username))
    ...
  • chain
    $validatorChain = new Zend_Validate();
    $validatorChain->addValidator(new Zend_Validate_NotEmpty())
    ->addValidator(new Zend_Validate_Alnum()));

  • 自訂訊息
    $alnum = new Zend_Validate_Alnum();
    $alnum->setMessage('非數字');

    Zend_Validate_EmailAddress的setMessage沒反應,v1.11前都還沒修好

沒有留言: