PHP Zend Framework - 验证器示例

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP Zend Framework - 验证器示例相关的知识,希望对你有一定的参考价值。

$validators = array( 
             'address' => array('Alnum', new Zend_Validate_Alnum(true), 
                                'messages' => array( 
                                'Address not valid', // Default error message 
                                // Specific error messages 
                                array(Zend_Validate_Alnum::NOT_ALNUM => 
                                      'Address contains invalid characters', 
                                      Zend_Validate_Alnum::STRING_EMPTY => 
                                      'Address field is mandatory'))), 
             'phone'   => array('Digits', new Zend_Validate_Digits(), 
                                'messages' => array( 
                                'Wrong phone number format', 
                                array(Zend_Validate_Digits::NOT_DIGITS => 
                                      'Phone number can only have digits', 
                                      Zend_Validate_Digits::STRING_EMPTY => 
                                      'Phone number can not be empty'))), 
             'age'     => array('Digits', new Zend_Validate_Between(16, 59), 
                                'messages' => array( 
                                'You do not qualify because of your age', 
                                array(Zend_Validate_Between::NOT_BETWEEN => 
                                      'Age is not between the allowed range'))), 
             'id'      => array('StringLength', new Zend_Validate_StringLength(8, 10), 
                                'messages' => array( 
                                'ID not valid', 
                                array(Zend_Validate_StringLength::TOO_LONG => 
                                      'ID is too long', 
                                      Zend_Validate_StringLength::TOO_SHORT => 
                                      'ID is too short'))), 
             'date'    => array('Date', new Zend_Validate_Date(), 
                                'messages' => array( 
                                'Wrong date', 
                                array(Zend_Validate_Date::INVALID => 
                                      'Date not recognized as valid', 
                                      Zend_Validate_Date::FALSEFORMAT => 
                                      'Date format is incorrect', 
                                      Zend_Validate_Date::NOT_YYYY_MM_DD => 
                                     'Date format must be YYYY-MM-DD'))), 
              'url'      => $validurl 
           );

以上是关于PHP Zend Framework - 验证器示例的主要内容,如果未能解决你的问题,请参考以下文章

文件上传表单的 Zend 验证器大小 - Zend Framework 2.3

文件上传表单的 Zend 验证器大小 - Zend Framework 2.3

PHP Zend Framework:设置Zend Navigation

markdown Zend Framework 3:身份验证

php zend framework

在 Zend Framework 中获取 Session 过期时间