當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Validator::email方法代碼示例

本文整理匯總了PHP中Respect\Validation\Validator::email方法的典型用法代碼示例。如果您正苦於以下問題:PHP Validator::email方法的具體用法?PHP Validator::email怎麽用?PHP Validator::email使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Respect\Validation\Validator的用法示例。


在下文中一共展示了Validator::email方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: checkPasswordCredential

 /**
  * 檢查密碼是否正確
  *
  * @param string $field
  * @param string $password
  * @param bool $secretly
  * @return array
  * @throws UserException
  */
 public function checkPasswordCredential($field, $password, $secretly = false)
 {
     if (Validator::email()->validate($field)) {
         $user = UserUtil::getUserObjectByEmail($field);
     } else {
         $user = UserUtil::getUserObjectByUsername($field);
     }
     if (!UserUtil::isUserObjectValid($user)) {
         if (!$secretly) {
             Application::emit('user.login.failed.user_invalid', [VJ::LOGIN_TYPE_FAILED_USER_INVALID, $field]);
             Application::info('credential.login.not_found', ['login' => $field]);
         }
         throw new UserException('UserCredential.checkPasswordCredential.user_not_valid');
     }
     $verified = $this->password_encoder->verify($password, $user['salt'], $user['hash']);
     if (!$verified) {
         if (!$secretly) {
             Application::emit('user.login.failed.wrong_password', [VJ::LOGIN_TYPE_FAILED_WRONG_PASSWORD, $user]);
             Application::info('credential.login.wrong_password', ['uid' => $user['uid']]);
         }
         throw new UserException('UserCredential.checkPasswordCredential.wrong_password');
     }
     if (!$secretly) {
         Application::emit('user.login.succeeded', [VJ::LOGIN_TYPE_INTERACTIVE, $user, $field, $password]);
         Application::info('credential.login.ok', ['uid' => $user['uid']]);
     }
     return $user;
 }
開發者ID:Tanklong,項目名稱:openvj,代碼行數:37,代碼來源:UserCredential.php

示例2: validate

 public function validate($data)
 {
     $validator = V::key('name', V::string()->length(0, 100), true)->key('email', V::email()->length(0, 200), true)->key('password', V::string()->length(0, 100), true);
     try {
         $validator->assert($data);
         switch ($data['userable_type']) {
             case 'Designer':
                 $this->designerCreationValidator->validate($data);
                 $data['userable_type'] = DesignerModel::class;
                 break;
             case 'Administrator':
                 $this->adminCreationValidator->validate($data);
                 $data['userable_type'] = AdministratorModel::class;
                 break;
             case 'Buyer':
                 $this->buyerCreationValidator->validate($data);
                 $data['userable_type'] = BuyerModel::class;
                 break;
             default:
                 break;
         }
     } catch (AbstractNestedException $e) {
         $errors = $e->findMessages(['email', 'length', 'in']);
         throw new ValidationException('Could not create user.', $errors);
     }
     return true;
 }
開發者ID:HOFB,項目名稱:HOFB,代碼行數:27,代碼來源:UserCreationValidator.php

示例3: initRule

 /**
  *  init valid rule
  */
 protected function initRule()
 {
     $this->validRule['id'] = v::numeric();
     $this->validRule['name'] = v::stringType()->length(1, 10);
     $this->validRule['email'] = v::email();
     $this->validRule['sex'] = v::intVal()->between(0, 1);
 }
開發者ID:CrabHo,項目名稱:example-lib-profile,代碼行數:10,代碼來源:ProfileData.php

示例4: isValid

 public function isValid($validation_data)
 {
     $errors = [];
     foreach ($validation_data as $name => $value) {
         if (isset($_REQUEST[$name])) {
             $rules = explode("|", $value);
             foreach ($rules as $rule) {
                 $exploded = explode(":", $rule);
                 switch ($exploded[0]) {
                     case 'min':
                         $min = $exploded[1];
                         if (Valid::stringType()->length($min)->Validate($_REQUEST[$name]) == false) {
                             $errors[] = $name . " must be at least " . $min . " characters long";
                         }
                         break;
                     case 'email':
                         if (Valid::email()->Validate($_REQUEST[$name]) == false) {
                             $errors[] = $name . " must be a valid email ";
                         }
                         break;
                     case 'equalTo':
                         if (Valid::equals($_REQUEST[$name])->Validate($_REQUEST[$exploded[1]]) == false) {
                             $errors[] = "Values do not match";
                         }
                         break;
                     default:
                         //do nothing
                 }
             }
         } else {
             $errors = "No value found";
         }
     }
     return $errors;
 }
開發者ID:pivnicki,項目名稱:acme,代碼行數:35,代碼來源:Validator.php

示例5: validatePasswordResetRequest

 public function validatePasswordResetRequest($email, $token)
 {
     Auth::restrictAccess('anonymous');
     $passwordResets = new PasswordResets();
     // This needs to go into base functions and return some kind of json message
     if (!v::email()->validate($email)) {
         return 'email dont comply';
     }
     if (!v::xdigit()->length(32, 32)->validate($token)) {
         return 'token dont comply';
     }
     $passwordReset = $passwordResets->show($email);
     // Not going to reveal whether the user account was found...
     if (empty($passwordReset['token']) || empty($passwordReset['created'])) {
         echo 'password reset request not found. forward. please submit a password reset request first';
         die;
     }
     $created = strtotime($passwordReset['created']);
     $now = strtotime(date('Y-m-d H:i:s'));
     $diff = round(($now - $created) / 60, 2);
     if (intval($diff) > 60) {
         echo 'password reset has expired. 60 minutes max. submit another reset request';
         die;
     }
     if (password_verify($token, $passwordReset['token'])) {
         // probably shouldnt disclose this. just send json success
         echo 'password matches. proceed to reset.';
     }
     return $passwordReset;
 }
開發者ID:aodkrisda,項目名稱:slim3-api,代碼行數:30,代碼來源:PasswordResetController.php

示例6: email

 /**
  * @param   $param
  * @return  string
  * @throws  EntityValidationException
  */
 public function email($param)
 {
     if (!v::email()->validate($param)) {
         throw new EntityValidationException('User', 'email', $param, 'Invalid email');
     }
     return $param;
 }
開發者ID:caravanarentals,項目名稱:php-wrapper,代碼行數:12,代碼來源:BaseUserValidation.php

示例7: validate

 public function validate($prop, $label)
 {
     $value = $this->getValue($prop);
     if (!v::email()->validate($value)) {
         $this->addException("O campo {$label} não contém um e-mail válido");
     }
 }
開發者ID:dindigital,項目名稱:din,代碼行數:7,代碼來源:StringEmail.php

示例8: setAlternativeEmail

 public function setAlternativeEmail($value)
 {
     if (!v::email()->validate($value)) {
         throw new FieldRequiredException("E-mail alternativo inválido");
     }
     $this->_email .= "," . $value;
 }
開發者ID:dindigital,項目名稱:nfe-focus,代碼行數:7,代碼來源:Receiver.php

示例9: isValid

 public function isValid($validation_data)
 {
     $errors = [];
     foreach ($validation_data as $name => $value) {
         $exploded = explode(":", $value);
         switch ($exploded[0]) {
             case 'min':
                 $min = $exploded[1];
                 if (Valid::stringType()->length($min, null)->Validate($_REQUEST[$name]) == false) {
                     $errors[] = $exploded[2] . " must be at least " . $min . " characters long ";
                 }
                 break;
             case 'email':
                 if (Valid::email()->Validate($_REQUEST[$name]) == false) {
                     $errors[] = "Please enter a valid email";
                 }
                 break;
             case 'equalTo':
                 if (Valid::equals($_REQUEST[$name])->Validate($_REQUEST[$exploded[1]]) == false) {
                     $errors[] = $exploded[2] . " value does not match " . $exploded[3] . " value";
                 }
                 break;
             default:
                 //do nothing
                 $errors[] = "No values found";
         }
     }
     return $errors;
 }
開發者ID:vortexcoaching,項目名稱:MQP_Alchemy__Truth,代碼行數:29,代碼來源:Validator.php

示例10: isValid

 public function isValid($validation_data)
 {
     $errors = [];
     foreach ($validation_data as $name => $value) {
         $rules = explode("|", $value);
         foreach ($rules as $rule) {
             $exploded = explode(":", $rule);
             switch ($exploded[0]) {
                 case 'min':
                     $min = $exploded[1];
                     if (Valid::stringType()->length($min, null)->Validate($_REQUEST[$name]) == false) {
                         $errors[] = $name . " must be at least " . $min . " characters long!";
                     }
                     break;
                 case 'email':
                     if (Valid::email()->Validate($_REQUEST[$name]) == false) {
                         $errors[] = $name . " must be a valid email address!";
                     }
                     break;
                 case 'equalTo':
                     if (Valid::equals($_REQUEST[$name])->Validate($_REQUEST[$exploded[1]]) == false) {
                         $errors[] = "Value does not match verification value!";
                     }
                     break;
                 default:
                     $errors[] = "No value found!";
             }
         }
     }
     return $errors;
 }
開發者ID:Damien1990,項目名稱:acme,代碼行數:31,代碼來源:Validator.php

示例11: isValid

 public function isValid($validation_data)
 {
     $errors = "";
     foreach ($validation_data as $name => $value) {
         $rules = explode("|", $value);
         foreach ($rules as $rule) {
             $exploded = explode(":", $rule);
             switch ($exploded[0]) {
                 case 'min':
                     $min = $exploded[1];
                     if (Valid::alpha()->length($min)->Validate($_POST[$name]) == false) {
                         $errors[] = $name . " must be at least " . $exploded[1] . " characters long!";
                     }
                     break;
                 case 'email':
                     if (Valid::email()->validate($_POST[$name]) == false) {
                         $errors[] = $name . " must be a valid email address!";
                     }
                     break;
                 case 'equalTo':
                     if (Valid::equals($_POST[$name])->validate($_POST[$exploded[1]]) == false) {
                         $errors[] = $name . "'s don't match!";
                     }
                     break;
                 default:
                     $errors[] = "No value found!";
                     break;
             }
         }
     }
     return $errors;
 }
開發者ID:jurajvuk,項目名稱:acme,代碼行數:32,代碼來源:Validator.php

示例12: send

 private function send($type, array $to, $subject, $template, $params)
 {
     if (!Validator::arr()->each(Validator::email())->validate($to)) {
         throw new InvalidArgumentException('to', 'format_invalid');
     }
     $html = Application::get('templating')->render($template, array_merge(['SUBJECT' => $subject], $params));
     $this->provider->send($type, $to, $subject, $html);
 }
開發者ID:Tanklong,項目名稱:openvj,代碼行數:8,代碼來源:Sender.php

示例13: setData

 public function setData($data)
 {
     if (!is_string($data) || !v::email()->validate($data)) {
         throw new \RuntimeException('EmailField data must be a valid representation of an email address ');
     }
     $this->data = $data;
     return $this;
 }
開發者ID:hectorbenitez,項目名稱:php-hypermedia-api,代碼行數:8,代碼來源:EmailField.php

示例14: validateEmail

 protected function validateEmail()
 {
     $value = v::email()->notEmpty()->validate($this->getEmail());
     if (!$value) {
         msg::showMsg('O campo E-mail deve ser preenchido corretamente.' . '<script>focusOn("email");</script>', 'danger');
     }
     $this->criptoVar('email', $this->getEmail());
     return $this;
 }
開發者ID:br-monteiro,項目名稱:HTR-Firebird-Framework,代碼行數:9,代碼來源:AuthValidatorTrait.php

示例15: create

 /**
  * Creates a profile.
  *
  * @param string $uniqueness
  * @param string $email
  *
  * @throws InvalidEmailException
  *
  * @return string
  */
 public function create($uniqueness, $email)
 {
     if (!Validator::email()->validate($email)) {
         throw new InvalidEmailException();
     }
     $uniqueness = $uniqueness ?: uniqid();
     $this->connectToStorage->connect()->insertOne(new Profile($uniqueness, $email));
     return $uniqueness;
 }
開發者ID:cubalider,項目名稱:internet-profile,代碼行數:19,代碼來源:CreateProfile.php


注:本文中的Respect\Validation\Validator::email方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。