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


PHP Zend_Validate_EmailAddress::isValid方法代码示例

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


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

示例1: processAction

 public function processAction()
 {
     $error = array();
     $defaultNamespace = new Zend_Session_Namespace('Default');
     $options = array('authentication' => array('email' => $this->getRequest()->getParam('admin_email'), 'password' => $this->getRequest()->getParam('admin_password')), 'settings' => array('default_from' => $this->getRequest()->getParam('default_from'), 'keep_history' => $this->getRequest()->getParam('keep_history'), 'alchemy_api_key' => $this->getRequest()->getParam('alchemy_api_key')), 'resources' => array('db' => array('adapter' => 'PDO_MYSQL', 'params' => array('host' => $this->getRequest()->getParam('db_host'), 'username' => $this->getRequest()->getParam('db_user'), 'password' => $this->getRequest()->getParam('db_password'), 'dbname' => $this->getRequest()->getParam('db_name'), 'prefix' => $this->getRequest()->getParam('db_prefix')))), 'template' => $this->getRequest()->getParam('template'));
     $validator = new Zend_Validate_EmailAddress();
     if (!$validator->isValid($options['authentication']['email'])) {
         $error['admin_email'] = 'Administrator e-mail is invalid';
     }
     if (!trim($options['authentication']['password'])) {
         $error['admin_password'] = 'Administrator password can not be blank';
     }
     if (!$validator->isValid($options['settings']['default_from'])) {
         $error['default_from'] = 'Default "from" e-mail is invalid';
     }
     if (!trim($options['resources']['db']['params']['host'])) {
         $error['db_host'] = 'Database host can not be blank';
     }
     if (!trim($options['resources']['db']['params']['username'])) {
         $error['db_user'] = 'Database user can not be blank';
     }
     if (!trim($options['resources']['db']['params']['dbname'])) {
         $error['db_name'] = 'Database name can not be blank';
     }
     if ((int) $options['settings']['keep_history'] <= 0) {
         $error['keep_history'] = 'Timeline display length have to be positive integer';
     }
     if (!($db = new Zend_Db_Adapter_Pdo_Mysql(array('host' => $options['resources']['db']['params']['host'], 'username' => $options['resources']['db']['params']['username'], 'password' => $options['resources']['db']['params']['password'], 'dbname' => $options['resources']['db']['params']['dbname'])))) {
         $error[] = 'Incorrect database connection details';
     }
     if (count($error)) {
         /**
          * Redirect back
          */
         $defaultNamespace->error = $error;
         $defaultNamespace->options = $options;
         $this->_helper->redirector('index', 'index', 'install');
     } else {
         /**
          * Write .ini file
          */
         unset($defaultNamespace->options);
         /** @var $bootstrap Bootstrap */
         $bootstrap = $this->getInvokeArg('bootstrap');
         $options = new Zend_Config($options);
         $writer = new Zend_Config_Writer_Xml();
         $writer->write($bootstrap->getOption('local_config'), $options);
         $options = $bootstrap->getOptions();
         $options = new Zend_Config($options);
         $writer->write('application.xml', $options);
         $this->_helper->redirector('index', 'index', 'default');
     }
 }
开发者ID:sepano,项目名称:open-social-media-monitoring,代码行数:53,代码来源:IndexController.php

示例2: testValidEmailAddresses

 /**
  * SW-8258 - check if email addresses with new domains like .berlin are valid
  */
 public function testValidEmailAddresses()
 {
     $emailAddresses = array('test@example.de', 'test@example.com', 'test@example.org', 'test@example.berlin', 'test@example.email', 'test@example.systems', 'test@example.active', 'test@example.love', 'test@example.video');
     $invalidEmailAddresses = array('test', 'test@example', 'test@.de', '@example', '@example.de', '@.', ' @ .de');
     $validator = new Zend_Validate_EmailAddress();
     $validator->getHostnameValidator()->setValidateTld(false);
     foreach ($emailAddresses as $email) {
         $this->assertTrue($validator->isValid($email));
     }
     foreach ($invalidEmailAddresses as $email) {
         $this->assertFalse($validator->isValid($email));
     }
 }
开发者ID:ClaudioThomas,项目名称:shopware-4,代码行数:16,代码来源:AccountTest.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: gravatar

 /**
  * Returns an avatar from gravatar's service.
  *
  * @link http://pl.gravatar.com/site/implement/url
  * @throws Zend_View_Exception
  *
  * @param string|null $email Valid email adress
  * @param null|array $options Options
  * 'imgSize' height of img to return
  * 'defaultImg' img to return if email adress has not found
  * 'rating' rating parameter for avatar
  * @param null|array $attribs Attribs for img tag (title, alt etc.)
  * @param null|bool Use HTTPS? Default false.
  * @link http://pl.gravatar.com/site/implement/url More information about gravatar's service.
  * @return string|Zend_View_Helper_Gravatar
  */
 public function gravatar($email = null, $options = array(), $attribs = array(), $flag = false)
 {
     if ($email === null) {
         return null;
     }
     if (count($options) > 0) {
         if (isset($options['imgSize'])) {
             $this->setImgSize($options['imgSize']);
         }
         if (isset($options['defaultImg'])) {
             $this->setDefaultImg($options['defaultImg']);
         }
         if (isset($options['rating'])) {
             $this->setRating($options['rating']);
         }
     }
     /**
      * @see Zend_Validate_EmailAddress
      */
     require_once 'Zend/Validate/EmailAddress.php';
     $validatorEmail = new Zend_Validate_EmailAddress();
     $validatorResult = $validatorEmail->isValid($email);
     if ($validatorResult === false) {
         return null;
     }
     $hashEmail = md5($email);
     $src = $this->getGravatarUrl($flag) . '/' . $hashEmail . '?s=' . $this->getImgSize() . '&d=' . $this->getDefaultImg() . '&r=' . $this->getRating();
     $attribs['src'] = $src;
     $html = '<img' . $this->_htmlAttribs($attribs) . $this->getClosingBracket();
     return $html;
 }
开发者ID:kminkov,项目名称:Blog,代码行数:47,代码来源:Gravatar.php

示例5: validateReceiverType

 /**
  * Validate that the receiver ID is well-formed according to it's type
  *
  * @param  string $value
  * @param  string $type Either EMAIL or PAYPAL ID
  * @return boolean
  */
 public static function validateReceiverType($value, $type)
 {
     switch ($type) {
         case self::RT_EMAIL:
             if (!self::$emailValidator) {
                 require_once 'Zend/Validate/EmailAddress.php';
                 self::$emailValidator = new Zend_Validate_EmailAddress();
             }
             return self::$emailValidator->isValid($value);
             break;
         case self::RT_USERID:
             if (!self::$useridValidator) {
                 require_once 'Zend/Validate.php';
                 require_once 'Zend/Validate/StringLength.php';
                 require_once 'Zend/Validate/Alnum.php';
                 self::$useridValidator = new Zend_Validate();
                 self::$useridValidator->addValidator(new Zend_Validate_StringLength(13))->addValidator(new Zend_Validate_Alnum());
             }
             return self::$useridValidator->isValid($value);
             break;
         default:
             require_once 'Zend/Service/PayPal/Data/Exception.php';
             throw new Zend_Service_PayPal_Data_Exception("'{$type}' is not a valid Receiver ID type");
             break;
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:33,代码来源:MassPayReceiver.php

示例6: _validateEmail

 protected function _validateEmail($value = null)
 {
     if ($value) {
         $validator = new Zend_Validate_EmailAddress();
         $validator->setMessage(Mage::helper('eav')->__('"%s" invalid type entered.', $value), Zend_Validate_EmailAddress::INVALID);
         $validator->setMessage(Mage::helper('eav')->__('"%s" is not a valid email address.', $value), Zend_Validate_EmailAddress::INVALID_FORMAT);
         $validator->setMessage(Mage::helper('eav')->__('"%s" is not a valid hostname.', $value), Zend_Validate_EmailAddress::INVALID_HOSTNAME);
         $validator->setMessage(Mage::helper('eav')->__('"%s" is not a valid hostname.', $value), Zend_Validate_EmailAddress::INVALID_MX_RECORD);
         $validator->setMessage(Mage::helper('eav')->__('"%s" is not a valid hostname.', $value), Zend_Validate_EmailAddress::INVALID_MX_RECORD);
         $validator->setMessage(Mage::helper('eav')->__('"%s" is not a valid email address.', $value), Zend_Validate_EmailAddress::DOT_ATOM);
         $validator->setMessage(Mage::helper('eav')->__('"%s" is not a valid email address.', $value), Zend_Validate_EmailAddress::QUOTED_STRING);
         $validator->setMessage(Mage::helper('eav')->__('"%s" is not a valid email address.', $value), Zend_Validate_EmailAddress::INVALID_LOCAL_PART);
         $validator->setMessage(Mage::helper('eav')->__('"%s" exceeds the allowed length.', $value), Zend_Validate_EmailAddress::LENGTH_EXCEEDED);
         $validator->setMessage(Mage::helper('customer')->__("'%value%' appears to be an IP address, but IP addresses are not allowed"), Zend_Validate_Hostname::IP_ADDRESS_NOT_ALLOWED);
         $validator->setMessage(Mage::helper('customer')->__("'%value%' appears to be a DNS hostname but cannot match TLD against known list"), Zend_Validate_Hostname::UNKNOWN_TLD);
         $validator->setMessage(Mage::helper('customer')->__("'%value%' appears to be a DNS hostname but contains a dash in an invalid position"), Zend_Validate_Hostname::INVALID_DASH);
         $validator->setMessage(Mage::helper('customer')->__("'%value%' appears to be a DNS hostname but cannot match against hostname schema for TLD '%tld%'"), Zend_Validate_Hostname::INVALID_HOSTNAME_SCHEMA);
         $validator->setMessage(Mage::helper('customer')->__("'%value%' appears to be a DNS hostname but cannot extract TLD part"), Zend_Validate_Hostname::UNDECIPHERABLE_TLD);
         $validator->setMessage(Mage::helper('customer')->__("'%value%' does not appear to be a valid local network name"), Zend_Validate_Hostname::INVALID_LOCAL_NAME);
         $validator->setMessage(Mage::helper('customer')->__("'%value%' appears to be a local network name but local network names are not allowed"), Zend_Validate_Hostname::LOCAL_NAME_NOT_ALLOWED);
         $validator->setMessage(Mage::helper('customer')->__("'%value%' appears to be a DNS hostname but the given punycode notation cannot be decoded"), Zend_Validate_Hostname::CANNOT_DECODE_PUNYCODE);
         if (!$validator->isValid($value)) {
             return array_unique($validator->getMessages());
         }
     }
     return;
 }
开发者ID:VinuWebtech,项目名称:production267,代码行数:27,代码来源:OnepageController.php

示例7: ceospeaksAction

 public function ceospeaksAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         // action body
         $emails_str = str_replace(" ", "", $request->getParam('emails'));
         // strips whitespace from string
         $emails = explode(",", $emails_str);
         // splits string into an array using comma to split
         $validator = new Zend_Validate_EmailAddress();
         foreach ($emails as $email) {
             if (!$validator->isValid($email)) {
                 array_shift($emails);
                 // Remove invalid emails
             }
         }
         $mail = new Zend_Mail();
         $mail->setFrom('suggestions@winsandwants.com', 'winsandwants.com');
         $mail->setReplyTo('suggestions@winsandwants.com', 'winsandwants.com');
         $mail->addTo($emails);
         $mail->setSubject('Sharing winsandwants.com');
         $txt = "A friend would like to share with you this wonderful free site on goal-setting and the mastermind concept. Please visit: http://winsandwants.com";
         $mail->setBodyText($txt, 'UTF-8');
         $mail->send();
         $this->view->msg = "Thank you for sharing this site. A link to this site has been sent to the following emails: " . implode(",", $emails) . ".";
     }
 }
开发者ID:jingjangjung,项目名称:WinsAndWants,代码行数:27,代码来源:IndexController.php

示例8: testComplexLocalValid

 /**
  * Ensures that the validator follows expected behavior for valid email addresses with complex local parts
  *
  * @return void
  */
 public function testComplexLocalValid()
 {
     $emailAddresses = array('Bob.Jones@domain.com', 'Bob.Jones!@domain.com', 'Bob&Jones@domain.com', '/Bob.Jones@domain.com', '#Bob.Jones@domain.com', 'Bob.Jones?@domain.com');
     foreach ($emailAddresses as $input) {
         $this->assertTrue($this->_validator->isValid($input));
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:12,代码来源:EmailAddressTest.php

示例9: gravatar

 /**
  * Returns an avatar from gravatar's service.
  *
  * @link http://en.gravatar.com/site/implement/images/php/
  * @throws Zend_View_Exception
  *
  * @param string|null $email Valid email adress
  * @param array $options Options
  * 'imgSize' height of img to return
  * 'defaultImg' img to return if email adress has not found
  * 'rating' rating parametr for avatar
  * @param array $attribs Attribs for img tag (title, alt etc.)
  * @param bool $flag Use HTTPS? Default false.
  * @return string
  */
 public function gravatar($email = null, $options = array(), $attribs = array(), $flag = false)
 {
     if ($email === null) {
         return '';
     }
     if (count($options) > 0) {
         if (isset($options['imgSize'])) {
             $this->setImgSize($options['imgSize']);
         }
         if (isset($options['defaultImg'])) {
             $this->setDefaultImg($options['defaultImg']);
         }
         if (isset($options['rating'])) {
             $this->setRating($options['rating']);
         }
     }
     $validatorEmail = new Zend_Validate_EmailAddress();
     $validatorResult = $validatorEmail->isValid($email);
     if ($validatorResult === false) {
         throw new Zend_View_Exception(current($validatorEmail->getMessages()));
     }
     $hashEmail = md5($email);
     $src = $this->getGravatarUrl($flag) . '/' . $hashEmail . '?s=' . $this->getImgSize() . '&d=' . $this->getDefaultImg() . '&r=' . $this->getRating();
     $attribs['src'] = $src;
     $html = '<img' . $this->_htmlAttribs($attribs) . $this->getClosingBracket();
     return $html;
 }
开发者ID:BGCX262,项目名称:zweer-gdr-svn-to-git,代码行数:42,代码来源:Gravatar.php

示例10: 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

示例11: registerAction

 public function registerAction()
 {
     $name = $this->_getParam('name');
     $avatar = $this->_getParam('avatar');
     $sex = $this->_getParam('sex');
     $birthday = $this->_getParam('birthday');
     $email = $this->_getParam('email');
     $passwd = $this->_getParam('passwd');
     $phone = $this->_getParam('phone');
     $department = $this->_getParam('department');
     $city = $this->_getParam('city');
     //$certified  = $this->_getParam('certified');
     $special = $this->_getParam('special');
     $country = $this->_getParam('country');
     $introduction = $this->_getParam('introduction');
     $hospital = $this->_getParam('hospital');
     $area = $this->_getParam('area');
     $qualification = $this->_getParam('qualification');
     if (!$passwd) {
         $out['errno'] = '3';
         $out['msg'] = Yy_ErrMsg_Doctor::getMsg('register', $out['errno']);
         Yy_Utils::jsonOut($out);
         return;
     }
     $validatorEmail = new Zend_Validate_EmailAddress();
     if ($validatorEmail->isValid($email)) {
         $bool = Application_Model_M_Doctor::fetchByEmail($email);
         if ($bool) {
             //已注册
             $out['errno'] = '1';
         } else {
             $out['errno'] = '0';
             $doctor = new Application_Model_O_Doctor();
             $doctor->setName($name)->setSex($sex)->setBirthday($birthday)->setEmail($email)->setPasswd(md5($passwd))->setPhone($phone)->setDepartment($department)->setCity($city)->setSpecial($special)->setCountry($country)->setIntroduction($introduction)->setHospital($hospital)->setArea($area)->setQualification($qualification)->setCtime(date('Y-m-d H:i:s'));
             $certified = ceil(count($doctor->getModifiedFields()) / 3);
             $doctor->setCertified($certified);
             $doctor->save();
             //保存医生头像
             $adapter = new Zend_File_Transfer_Adapter_Http();
             $wrdir = Yy_Utils::getWriteDir();
             $adapter->setDestination($wrdir);
             if (!$adapter->receive()) {
                 $messages = $adapter->getMessages();
                 //echo implode("\n", $messages);
             }
             $filename = $adapter->getFileName();
             if (is_string($filename)) {
                 $handle = fopen($filename, 'rb');
                 $avatar = addslashes(fread($handle, filesize($filename)));
                 fclose($handle);
                 Application_Model_M_Doctor::updateAvatar($doctor->getId(), $avatar);
             }
         }
     } else {
         $out['errno'] = '2';
     }
     $out['msg'] = Yy_ErrMsg_Doctor::getMsg('register', $out['errno']);
     Yy_Utils::jsonOut($out);
 }
开发者ID:baiooy,项目名称:hqimt_backend,代码行数:59,代码来源:DoctorController.php

示例12: 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

示例13: setSandboxPrimaryEmail

 public function setSandboxPrimaryEmail($email)
 {
     $validator = new Zend_Validate_EmailAddress();
     if (!$validator->isValid($email)) {
         throw new Exception($email . ' is not a valid email address!');
     }
     $this->_sandboxPrimaryEmail = $email;
 }
开发者ID:karlforshaw,项目名称:Zend-Paypal-Notification,代码行数:8,代码来源:PaypalNotification.php

示例14: setEmail

 public function setEmail($email)
 {
     $validator = new Zend_Validate_EmailAddress();
     if (!$validator->isValid($email)) {
         throw new Exception('Invalid e-mail address specified');
     }
     $this->_email = $email;
 }
开发者ID:vinnivinsachi,项目名称:Vincent-DR,代码行数:8,代码来源:EmailLogger.php

示例15: validateAttributeValue

 /**
  * Validate attributes
  * 
  * @param string $validation attribute validation class name
  * @param string $value attribute value
  * @return array returns success and errors as array keys
  */
 protected function validateAttributeValue($validation, $value)
 {
     $valid = array('success' => TRUE, 'errors' => '');
     switch ($validation) {
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_DECIMAL:
             if (!$this->decimalValidation) {
                 $this->decimalValidation = new Zend_Validate_Float();
             }
             $valid['success'] = $this->decimalValidation->isValid($value);
             $valid['errors'] = '"' . $value . '" contains invalid digits.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_EMAIL:
             if (!$this->emailValidation) {
                 $this->emailValidation = new Zend_Validate_EmailAddress();
             }
             $valid['success'] = $this->emailValidation->isValid($value);
             $valid['errors'] = '"' . $value . '" is not a valid email address.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_INT:
             if (!$this->intValidation) {
                 $this->intValidation = new Zend_Validate_Int();
             }
             $valid['success'] = $this->intValidation->isValid($value);
             $valid['errors'] = '"' . $value . '" is not a valid integer.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_LETTERS:
             if (!$this->letterValidation) {
                 $this->letterValidation = new Zend_Validate_Alpha(true);
             }
             $valid['success'] = $this->letterValidation->isValid($value);
             $valid['errors'] = '"' . $value . '" contains invalid characters.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_DATE:
             $valid['success'] = strtotime($value) > 0;
             $valid['errors'] = '"' . $value . '" is invalid date.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_URL:
             if (!$this->urlValidation) {
                 $this->urlValidation = new Uni_Validate_Url();
             }
             $valid['success'] = $this->urlValidation->isValid($value);
             $valid['errors'] = '"' . $value . '" is not a valid url.';
             break;
         case Fox_Eav_Model_Attribute::ATTRIBUTE_VALIDATION_IMAGE:
             if (empty($this->validExtensions)) {
                 $this->validExtensions = array('jpg', 'jpeg', 'png', 'bmp', 'gif', 'tiff');
             }
             $extPos = strrpos($value, '.');
             if (!$extPos || !empty($this->validExtensions) && !in_array(substr($value, $extPos + 1), $this->validExtensions)) {
                 $valid['success'] = FALSE;
                 $valid['errors'] = 'Invalid image was given.';
             }
             break;
         default:
             break;
     }
     return $valid;
 }
开发者ID:UnicodeSystems-PrivateLimited,项目名称:Zendfox,代码行数:65,代码来源:Abstract.php


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