当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Validate::isValid方法代码示例

本文整理汇总了PHP中Zend_Validate::isValid方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Validate::isValid方法的具体用法?PHP Zend_Validate::isValid怎么用?PHP Zend_Validate::isValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Validate的用法示例。


在下文中一共展示了Zend_Validate::isValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testBreakChainOnFailure

 /**
  * Ensures that a validator may break the chain
  *
  * @return void
  */
 public function testBreakChainOnFailure()
 {
     $this->_validator->addValidator(new Zend_ValidateTest_False(), true)->addValidator(new Zend_ValidateTest_False());
     $this->assertFalse($this->_validator->isValid(null));
     $this->assertEquals(array('validation failed'), $this->_validator->getMessages());
     $this->assertEquals(array('error'), $this->_validator->getErrors());
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:12,代码来源:ValidateTest.php

示例2: mailAction

 public function mailAction()
 {
     $error = array();
     $posts = array('First Name' => $_POST['first_name'], 'Last Name' => $_POST['last_name'], 'Email' => $_POST['email'], 'Message' => $_POST['message']);
     $validatorChain = new Zend_Validate();
     $validatorChain->addValidator(new Zend_Validate_NotEmpty());
     $valid_email = new Zend_Validate_EmailAddress();
     if ($valid_email->isValid($posts['Email'])) {
     } else {
         foreach ($valid_email->getMessages() as $message) {
             $error[] = "Email {$message}\n";
         }
     }
     foreach ($posts as $key => $post) {
         if ($validatorChain->isValid($post)) {
         } else {
             foreach ($validatorChain->getMessages() as $message) {
                 $error[] = "{$key} {$message}\n";
             }
         }
     }
     if (count($error) != 0) {
         $this->view->alerts = $error;
     } else {
         $to = 'illustratedpdx@gmail.com';
         $subject = 'Email from Illustrated Portland';
         $message = $posts['Message'];
         $headers = "From: {$posts['First Name']} {$posts['Last Name']} <{$posts['Email']}>";
         mail($to, $subject, $message, $headers);
         //$this->view->alerts = array("Thank You! Your message has been sent.");
     }
 }
开发者ID:kellancraddock,项目名称:illustrated_portland,代码行数:32,代码来源:ContactController.php

示例3: isValid

 /**
  * Make sure the user is valid
  *
  * @return void
  */
 public function isValid($value)
 {
     $valid = true;
     $this->_user = $value;
     $namePartsValidator = new Zend_Validate();
     $namePartsValidator->addValidator(new Zend_Validate_NotEmpty(Zend_Validate_NotEmpty::STRING))->addValidator(new Zend_Validate_Alpha(array('allowWhiteSpace' => true)))->addValidator(new Zend_Validate_StringLength(array('min' => 2)));
     if (!$namePartsValidator->isValid($this->_user->getFirstName())) {
         $valid = false;
         $this->_error($this->_view->translate('The first name must have at least 2 characters and consist only of letters'));
     }
     if (!$namePartsValidator->isValid($this->_user->getLastName())) {
         $valid = false;
         $this->_error($this->_view->translate('The last name must have at least 2 characters and consist only of letters'));
     }
     $emailValidator = new Zend_Validate_EmailAddress();
     if (!$emailValidator->isValid($this->_user->getEmail())) {
         $valid = false;
         $this->_error($this->_view->translate('You must entre a valid email'));
     }
     if ($this->_user->isNew()) {
         $usernameValidator = new Zend_Validate();
         $usernameValidator->addValidator(new Zend_Validate_NotEmpty(Zend_Validate_NotEmpty::STRING))->addValidator(new Zend_Validate_Alnum(array('allowWhiteSpace' => false)))->addValidator(new Zend_Validate_StringLength(array('min' => 5)));
         if (!$usernameValidator->isValid($this->_user->getUsername())) {
             $this->_error($this->_view->translate('The username must have at least 5 characters and contains no white spaces'));
         }
     }
     return $valid;
 }
开发者ID:EricHogue,项目名称:Koryukan,代码行数:33,代码来源:UserValidator.php

示例4: indexAction

 public function indexAction()
 {
     $emailValidator = new Zend_Validate_EmailAddress();
     $nameValidator = new Zend_Validate_NotEmpty(array(Zend_Validate_NotEmpty::STRING, Zend_Validate_NotEmpty::SPACE));
     $password1_Validator = new Zend_Validate();
     $password1_Validator->addValidator(new Zend_Validate_StringLength(array('min' => 6, 'max' => 12)))->addValidator(new Zend_Validate_Alnum());
     $password2_Validator = new Zend_Validate();
     $password2_Validator->addValidator(new Zend_Validate_StringLength(array('min' => 6, 'max' => 12)))->addValidator(new Zend_Validate_Alnum());
     $captcha = new Zend_Captcha_Image();
     $captcha->setName('captchaword')->setFont(APPLICATION_PATH . '/data/arial.ttf')->setFontSize(28)->setImgDir(APPLICATION_PATH . '/../public/img')->setImgUrl('/img')->setWordLen(5)->setDotNoiseLevel(20)->setExpiration(300);
     $request = $this->getRequest();
     $post = $request->getPost();
     // $passwordIdentical = new Zend_Validate_Identical(array('token' => $post['password1']));
     $messages = array();
     $error = array();
     $noValiError = true;
     if ($this->getRequest()->isPost()) {
         if (!$emailValidator->isValid($post['user-email'])) {
             $error['user-emailVali'] = '請輸入正確的Email帳號';
             $noValiError = false;
         }
         if (!$nameValidator->isValid($post['name'])) {
             $error['nameVali'] = '姓名必填';
             $noValiError = false;
         }
         if (!$password1_Validator->isValid($post['password1'])) {
             $error['password1_Vali'] = '1.密碼長度需介於6~12之間,而且只能使用數字、英文';
             $noValiError = false;
         }
         if (!$password2_Validator->isValid($post['password2'])) {
             $error['password2_Vali'] = '1.密碼長度需介於6~12之間,而且只能使用數字、英文';
             $noValiError = false;
         }
         if (isset($post['password1']) && isset($post['password2']) && !($post['password1'] == $post['password2'])) {
             $error['passwordIdentical'] = '2.密碼輸入不同';
             $noValiError = false;
         }
         if (!($post['agree'] == 1)) {
             $error['agreeVali'] = '需同意服務條款及隱私權政策,才可以註冊';
             $noValiError = false;
         }
         if (!$captcha->isValid($post['captchaword'])) {
             $error['captchawordVali'] = '認證碼輸入錯誤';
             $noValiError = false;
         }
         if ($noValiError) {
             // register process
             $this->_signup($post);
             $this->view->messages = $post;
             $this->redirect('index/index');
         } else {
             $this->_genCaptcha($captcha);
             $this->view->error = $error;
             $this->view->messages = $post;
         }
     } else {
         $this->_genCaptcha($captcha);
     }
 }
开发者ID:ChenYoyo,项目名称:NLC-Event-Platform,代码行数:59,代码来源:SignupController.php

示例5: security

 /**
  * Security checks
  *
  * @throws Exception
  * @return void
  */
 public function security()
 {
     if (!$this->validator->isValid($this->get_request())) {
         foreach ($this->validator->getMessages() as $message) {
             throw new Exception($message);
         }
     }
 }
开发者ID:bgao-ca,项目名称:moodle-local_mr,代码行数:14,代码来源:abstract.php

示例6: __construct

 /**
  * Constructor.
  *
  * @param  string  $host OPTIONAL Hostname of remote connection (default: 127.0.0.1)
  * @param  integer $port OPTIONAL Port number (default: null)
  * @throws Zend_Mail_Protocol_Exception
  * @return void
  */
 public function __construct($host = '127.0.0.1', $port = null)
 {
     $this->_validHost = new Zend_Validate();
     $this->_validHost->addValidator(new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_ALL));
     if (!$this->_validHost->isValid($host)) {
         require_once 'Zend/Mail/Protocol/Exception.php';
         throw new Zend_Mail_Protocol_Exception(join(', ', $this->_validHost->getMessages()));
     }
     $this->_host = $host;
     $this->_port = $port;
 }
开发者ID:vojtajina,项目名称:sitellite,代码行数:19,代码来源:Abstract.php

示例7: validInput

 public function validInput($data)
 {
     $validator = new Zend_Validate();
     //$validator->addValidator(new Zend_Validate_Int());
     if ($validator->isValid($data)) {
         return $data;
     } else {
         //$this->_model->isValid = false;
         return $this->_info['errMsg'];
     }
 }
开发者ID:laiello,项目名称:xinhuxi,代码行数:11,代码来源:Text.php

示例8: __construct

 public function __construct($arrParam = array(), $options = null)
 {
     //////////////////////////////////
     //Kiem tra Name /////////////
     //////////////////////////////////
     if ($arrParam['action'] == 'add') {
         $options = array('table' => 'da_album', 'field' => 'album_name');
     } elseif ($arrParam['action'] == 'edit') {
         $options = array('table' => 'da_album', 'field' => 'album_name', 'exclude' => array('field' => 'id', 'value' => $arrParam['id']));
     }
     $validator = new Zend_Validate();
     $validator->addValidator(new Zend_Validate_NotEmpty(), true)->addValidator(new Zend_Validate_StringLength(3, 100), true);
     if (!$validator->isValid($arrParam['album_name'])) {
         $message = $validator->getMessages();
         $this->_messageError['album_name'] = 'Tên album: ' . current($message);
         $arrParam['album_name'] = '';
     }
     //////////////////////////////////
     //Kiem tra Picture small ///////////
     //////////////////////////////////
     $upload = new Zend_File_Transfer_Adapter_Http();
     $fileInfo = $upload->getFileInfo('picture');
     $fileName = $fileInfo['picture']['name'];
     if (!empty($fileName)) {
         $upload->addValidator('Extension', true, array('jpg', 'gif', 'png'), 'picture');
         $upload->addValidator('Size', true, array('min' => '2KB', 'max' => '1000KB'), 'picture');
         if (!$upload->isValid('picture')) {
             $message = $upload->getMessages();
             $this->_messageError['picture'] = 'Hình ảnh đại diện: ' . current($message);
         }
     }
     //////////////////////////////////
     //Kiem tra Order /////////////
     //////////////////////////////////
     $validator = new Zend_Validate();
     $validator->addValidator(new Zend_Validate_StringLength(1, 10), true)->addValidator(new Zend_Validate_Digits(), true);
     if (!$validator->isValid($arrParam['order'])) {
         $message = $validator->getMessages();
         $this->_messageError['order'] = 'Sắp xếp: ' . current($message);
         $arrParam['order'] = '';
     }
     //////////////////////////////////
     //Kiem tra Status /////////////
     //////////////////////////////////
     if (empty($arrParam['status']) || !isset($arrParam['status'])) {
         $arrParam['status'] = 0;
     }
     //========================================
     // TRUYEN CAC GIA TRI DUNG VAO MANG $_arrData
     //========================================
     $this->_arrData = $arrParam;
 }
开发者ID:brianbui171,项目名称:website_zend_1.11,代码行数:52,代码来源:ValidateAlbum.php

示例9: isValidText

 public function isValidText($value, $maxLenghtValue)
 {
     $validator = new Zend_Validate();
     // Create a validator chain and add validators to it
     $validator->addValidator(new Zend_Validate_NotEmpty())->addValidator(new Zend_Validate_StringLength(1, $maxLenghtValue));
     // Validate the value
     if ($validator->isValid($value)) {
         return true;
     } else {
         // value failed validation; print reasons
         foreach ($validator->getMessages() as $message) {
             return array('Error' => $message);
         }
     }
 }
开发者ID:roycocup,项目名称:Tests,代码行数:15,代码来源:Validator.php

示例10: indexAction

 /**
  * login page : 1. Validation 2. Login process
  */
 public function indexAction()
 {
     $passwordValidator = new Zend_Validate();
     $passwordValidator->addValidator(new Zend_Validate_StringLength(array('min' => 6, 'max' => 12)))->addValidator(new Zend_Validate_Alnum());
     $emailValidator = new Zend_Validate_EmailAddress();
     $captcha = new Zend_Captcha_Image();
     $captcha->setName('captchaword')->setFont(APPLICATION_PATH . '/data/arial.ttf')->setFontSize(28)->setImgDir(APPLICATION_PATH . '/../public/img')->setImgUrl('/img')->setWordLen(5)->setDotNoiseLevel(20)->setExpiration(300);
     $request = $this->getRequest();
     $post = $request->getPost();
     $messages = array();
     $noValiError = true;
     if ($this->getRequest()->isPost()) {
         if (!$passwordValidator->isValid($post['password'])) {
             $messages['passwordVali'] = '密碼長度需介於6~12之間,而且只能使用數字、英文';
             $noValiError = false;
         }
         if (!$emailValidator->isValid($post['user-email'])) {
             $messages['user-emailVali'] = '請輸入正確的Email帳號';
             $noValiError = false;
         }
         if (!$captcha->isValid($post['captchaword'])) {
             $messages['captchawordVali'] = '認證碼輸入錯誤';
             $noValiError = false;
         }
         $messages['password'] = $post['password'];
         $messages['user-email'] = $post['user-email'];
         if ($noValiError) {
             // login process
             $this->_checkAccount($post);
             $this->view->messages = $messages;
         } else {
             $this->_genCaptcha($captcha);
             $this->view->messages = $messages;
         }
     } else {
         $this->_genCaptcha($captcha);
     }
     if (Zend_Auth::getInstance()->hasIdentity() && $noValiError) {
         $this->redirect('index/index');
     }
 }
开发者ID:ChenYoyo,项目名称:NLC-Event-Platform,代码行数:44,代码来源:LoginController.php

示例11: loadById

 public function loadById($globalData, $object_id)
 {
     $validatorChain = new Zend_Validate();
     $validatorChain->addValidator(new Zend_Validate_Int());
     if (!$validatorChain->isValid($object_id)) {
         return NULL;
     }
     $db = $globalData->takeConnection();
     $table = new RealEstateAgency_Database_Area_Table(array('db' => $db));
     $where = $db->quoteInto('obj_id = ?', $object_id);
     $rowset = $table->fetchAll($where);
     $row = $rowset->current();
     if ($row) {
         $new_object = new RealEstateAgency_Object_Area();
         $new_object->setGlobalData($globalData);
         $new_object->fillByZendRow($row);
         return $new_object;
     } else {
         return NULL;
     }
 }
开发者ID:igorkovalchuk,项目名称:basic-real-estate-engine-ua,代码行数:21,代码来源:Area.php

示例12: __construct

 public function __construct($arrParam = array(), $options = null)
 {
     //////////////////////////////////
     //Kiem tra group_name /////////////
     //////////////////////////////////
     if ($arrParam['action'] == 'add') {
         $options = array('table' => 'da_user_group', 'field' => 'group_name');
     } elseif ($arrParam['action'] == 'edit') {
         $options = array('table' => 'da_user_group', 'field' => 'group_name', 'exclude' => array('field' => 'id', 'value' => $arrParam['id']));
     }
     $validator = new Zend_Validate();
     $validator->addValidator(new Zend_Validate_NotEmpty(), true)->addValidator(new Zend_Validate_StringLength(3, 32), true)->addValidator(new Zend_Validate_Regex('#^[a-zA-Z0-9\\-_\\.\\s]+$#'), true)->addValidator(new Zend_Validate_Db_NoRecordExists($options), true);
     if (!$validator->isValid($arrParam['group_name'])) {
         $message = $validator->getMessages();
         $this->_messageError['group_name'] = 'Group name: ' . current($message);
         $arrParam['group_name'] = '';
     }
     //////////////////////////////////
     //Kiem tra Avatar ///////////
     //////////////////////////////////
     $upload = new Zend_File_Transfer_Adapter_Http();
     $fileInfo = $upload->getFileInfo('avatar');
     $fileName = $fileInfo['avatar']['name'];
     if (!empty($fileName)) {
         $upload->addValidator('Extension', true, array('jpg', 'gif', 'png'), 'avatar');
         $upload->addValidator('Size', true, array('min' => '2KB', 'max' => '1000KB'), 'avatar');
         if (!$upload->isValid('avatar')) {
             $message = $upload->getMessages();
             $this->_messageError['avatar'] = 'Avatar: ' . current($message);
         }
     }
     //////////////////////////////////
     //Kiem tra ranking ///////////
     //////////////////////////////////
     $upload = new Zend_File_Transfer_Adapter_Http();
     $fileInfo = $upload->getFileInfo('ranking');
     $fileName = $fileInfo['ranking']['name'];
     if (!empty($fileName)) {
         $upload->addValidator('Extension', true, array('jpg', 'gif', 'png'), 'ranking');
         $upload->addValidator('Size', true, array('min' => '2KB', 'max' => '1000KB'), 'ranking');
         if (!$upload->isValid('ranking')) {
             $message = $upload->getMessages();
             $this->_messageError['ranking'] = 'Ranking: ' . current($message);
         }
     }
     //////////////////////////////////
     //Kiem tra Admin Control Panel /////////////
     //////////////////////////////////
     if (empty($arrParam['group_acp']) || !isset($arrParam['group_acp'])) {
         $arrParam['group_acp'] = 0;
     }
     //////////////////////////////////
     //Kiem tra Group Default /////////////
     //////////////////////////////////
     if (empty($arrParam['group_default']) || !isset($arrParam['group_default'])) {
         $arrParam['group_default'] = 0;
     }
     //////////////////////////////////
     //Kiem tra Status /////////////
     //////////////////////////////////
     if (empty($arrParam['status']) || !isset($arrParam['status'])) {
         $arrParam['status'] = 0;
     }
     //////////////////////////////////
     //Kiem tra order /////////////
     //////////////////////////////////
     $validator = new Zend_Validate();
     $validator->addValidator(new Zend_Validate_Digits(), true);
     if (!$validator->isValid($arrParam['order'])) {
         $message = $validator->getMessages();
         $this->_messageError['order'] = 'Order: ' . current($message);
         $arrParam['order'] = '';
     }
     //========================================
     // TRUYEN CAC GIA TRI DUNG VAO MANG $_arrData
     //========================================
     $this->_arrData = $arrParam;
 }
开发者ID:brianbui171,项目名称:website_zend_1.11,代码行数:78,代码来源:ValidateUserGroup.php

示例13: editAction

 function editAction()
 {
     $errors = array();
     $users_table = new Users();
     $users_roles_table = new UsersRoles();
     $request = new Bolts_Request($this->getRequest());
     $countries_table = new Countries();
     $this->view->countries = $countries_table->getCountriesArray('Choose a country...');
     $roles_table = new Roles();
     $roles = $roles_table->fetchAll(NULL, "shortname ASC");
     $arRoles = array();
     foreach ($roles as $role) {
         if (!strpos($role->shortname, "-base")) {
             $arRoles[$role->id] = $role->description;
         }
     }
     $this->view->roles = $arRoles;
     $is_new = true;
     $user = array();
     if ($request->has('username')) {
         $obUser = $users_table->fetchByUsername($request->username);
         if (!is_null($obUser)) {
             $is_new = false;
             $user_roles = $users_roles_table->fetchAll($users_roles_table->select()->where("username = ?", $obUser->username));
             if (count($user_roles) > 0) {
                 $tmp_selected = array();
                 foreach ($user_roles as $user_role) {
                     $tmp_selected[] = $user_role->role_id;
                 }
                 $this->view->selected_roles = $tmp_selected;
             }
             $user = $obUser->toArray();
         }
     }
     $this->view->is_new = $is_new;
     if ($is_new) {
         // defaults for form fields
         $user['username'] = "";
         $user['full_name'] = "";
         $user['aboutme'] = "";
     }
     $pre_render = $this->_Bolts_plugin->doFilter($this->_mca . "_pre_render", array('user' => $user, 'request' => $this->_request));
     // FILTER HOOK
     $user = $pre_render['user'];
     foreach ($pre_render as $key => $value) {
         if ($key != "user") {
             $this->view->{$key} = $value;
         }
     }
     // $tags = unserialize($user['tags']);
     if ($this->getRequest()->isPost()) {
         $errors = array();
         $request->stripTags(array('full_name', 'email', 'newpassword', 'confirm'));
         // $request->stripTags(array('full_name', 'email', 'newpassword', 'confirm', 'aboutme'));
         $user['username'] = $request->username;
         $user['email'] = $request->email;
         $user['password'] = $request->newpassword;
         $user['confirm'] = $request->confirm;
         $user['full_name'] = $request->full_name;
         $user['birthday'] = $birthday = strtotime($request->Birthday_Day . $request->Birthday_Month . $request->Birthday_Year);
         $user['gender'] = $request->gender;
         $user['country_code'] = $request->country_code;
         $user['aboutme'] = $request->aboutme;
         // validate username
         $username_validator = new Zend_Validate();
         $username_validator->addValidator(new Zend_Validate_StringLength(1, Bolts_Registry::get('username_length')));
         $username_validator->addValidator(new Zend_Validate_Alnum());
         if (!$username_validator->isValid($user['username'])) {
             $show_username = "'" . $user['username'] . "'";
             if (trim($user['username']) == "") {
                 $show_username = "[" . $this->_T("empty") . "]";
             }
             $errors[] = $this->_T("%s isn't a valid username. (Between %d and %d characters, only letters and numbers)", array($show_username, 1, Bolts_Registry::get('username_length')));
         }
         if ($is_new) {
             $user_where = $users_table->getAdapter()->quoteInto('username = ?', $user['username']);
             if ($users_table->getCountByWhereClause($user_where) > 0) {
                 $errors[] = $this->_T("The username '%s' is already in use", $user['username']);
             }
         }
         // validate email
         if (!Bolts_Validate::checkEmail($user['email'])) {
             $errors[] = $this->_T("Email is not valid");
         }
         // check to see if email is in use already by someone else
         if ($users_table->isEmailInUse($user['email'], $user['username'])) {
             $errors[] = $this->_T("Email already in use");
         }
         // if password isn't blank, validate it
         if ($user['password'] != "") {
             if (!Bolts_Validate::checkLength($user['password'], 6, Bolts_Registry::get('password_length'))) {
                 $errors[] = $this->_T("Password must be between 6 and 32 characters");
             }
             // if password is set, make sure it matches confirm
             if ($user['password'] != $user['confirm']) {
                 $errors[] = $this->_T("Passwords don't match");
             }
         }
         // convert birthday_ts to mysql date
         $birthday = date("Y-m-d H:i:s", $user['birthday']);
//.........这里部分代码省略.........
开发者ID:jaybill,项目名称:Bolts,代码行数:101,代码来源:UseradminController.php

示例14: isValid

 /**
  * Validate the normalized new value.
  * Returns true if there are no validators or if validation passes,
  * returns the array of error messages if validators fail.
  *
  * @return boolean|array
  */
 public function isValid()
 {
     if ($this->_validator_chain === null) {
         return true;
     }
     if ($this->_validator_chain->isValid($this->getNormalizedNewValue())) {
         return true;
     }
     return $this->_validator_chain->getMessages();
 }
开发者ID:eliudiaz,项目名称:p4a,代码行数:17,代码来源:field.php

示例15: isValid

 /**
  * @return bool
  */
 public function isValid()
 {
     $tableColumns = $this->_table->getColumns();
     $dirtyColumns = $this->_data->getModified();
     foreach ($dirtyColumns as $key => $value) {
         unset($dirtyColumns[$key]);
         $dirtyColumns[strtolower($key)] = $value;
     }
     #die(Zend_Debug::dump($tableColumns));
     foreach ($tableColumns as $columnName => $columnStructure) {
         if (array_key_exists($columnName, $dirtyColumns)) {
             $validatorChain = new Zend_Validate();
             // Notnull
             if (array_key_exists('notnull', $columnStructure)) {
                 $validatorChain->addValidator(new Zend_Validate_NotEmpty(array('string' => true, 'empty_array' => true, 'null' => true, 'space' => true)));
             }
             // Email
             if (array_key_exists('email', $columnStructure)) {
                 $validatorChain->addValidator(new Zend_Validate_EmailAddress());
             }
             // Notblank
             if (array_key_exists('notblank', $columnStructure)) {
                 $validatorChain->addValidator(new Kebab_Validate_NotBlank());
             }
             // Nospace
             if (array_key_exists('nospace', $columnStructure)) {
                 // check null
                 $validatorChain->addValidator(new Zend_Validate_NotEmpty(array('null' => true)));
                 // check space
                 $validatorChain->addValidator(new Zend_Validate_Regex(array('pattern' => '/\\s/')));
             }
             // Past
             // Future
             // Min Length
             if (array_key_exists('minlength', $columnStructure)) {
                 $validatorChain->addValidator(new Zend_Validate_GreaterThan(array('min' => $columnStructure['minlength'])));
             }
             // Country
             // Ip
             if (array_key_exists('ip', $columnStructure)) {
                 $validatorChain->addValidator(new Zend_Validate_Ip());
             }
             // HtmlColor
             // Range
             if (array_key_exists('range', $columnStructure)) {
                 $validatorChain->addValidator(new Zend_Validate_Between(array('min' => $columnStructure['range'][0], 'max' => $columnStructure['range'][1])));
             }
             //Unique
             if (array_key_exists('unique', $columnStructure)) {
                 $validatorChain->addValidator(new Kebab_Validate_Unique($columnName, $this->_data));
             }
             // Regex
             if (array_key_exists('regexp', $columnStructure)) {
                 $validatorChain->addValidator(new Zend_Validate_Regex(array('pattern' => $columnStructure['regexp'])));
             }
             // Digits
             if (array_key_exists('digits', $columnStructure)) {
                 $validatorChain->addValidator(new Zend_Validate_Digits());
             }
             // Date
             if (array_key_exists('date', $columnStructure)) {
                 $validatorChain->addValidator(new Zend_Validate_Date());
             }
             // CC
             if (array_key_exists('cc', $columnStructure)) {
                 $validatorChain->addValidator(new Zend_Validate_CreditCard());
             }
             // Unsigned
             // Check All
             if (!$validatorChain->isValid($dirtyColumns[$columnName])) {
                 $translator = Zend_Registry::get('Zend_Translate');
                 Zend_Validate_Abstract::setDefaultTranslator($translator);
                 $this->_errors[$columnName] = $validatorChain->getMessages();
             }
             unset($validatorChain);
         }
     }
     if (count($this->_errors) > 0) {
         return false;
     } else {
         return true;
     }
 }
开发者ID:esironal,项目名称:kebab-project,代码行数:86,代码来源:DoctrineTable.php


注:本文中的Zend_Validate::isValid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。