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


PHP Validator::phone方法代碼示例

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


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

示例1: setData

 /**
  * (non-PHPdoc)
  * 
  * @see \Solvire\API\Serializers\DataFields\DataField::setData()
  */
 public function setData($data)
 {
     if (!is_string($data) || !v::phone()->validate($data)) {
         throw new \RuntimeException('PhoneNumberField data must be a valid representation of a phone number: ' . $data . ' in ' . $this->name);
     }
     $this->data = $data;
     return $this;
 }
開發者ID:solvire,項目名稱:php-hypermedia-api,代碼行數:13,代碼來源:PhoneField.php

示例2: validate

 public function validate($prop, $label)
 {
     $v = $this->getValue($prop);
     $v = preg_replace('/[^0-9]+/', '', $v);
     if (!v::phone()->validate($v)) {
         $this->addException("O número informado no campo {$label} está inválido");
     } else {
         return true;
     }
 }
開發者ID:dindigital,項目名稱:din,代碼行數:10,代碼來源:Phone.php

示例3: phone

 /**
  * 檢測手機號碼是否正確
  *
  * @param  string $value 手機號碼
  * @return bool
  */
 public static function phone($value)
 {
     return Validator::phone()->validate($value);
 }
開發者ID:tourze,項目名稱:base,代碼行數:10,代碼來源:Valid.php

示例4:

 }
 if (v::not(v::alnum("-.,()'"))->validate($form_data['requester_lname'])) {
     $err_msg .= "Your last name must be alphanumeric.\\n";
 }
 if (v::not(v::alnum("-.,()'"))->validate($form_data['emp_fname'])) {
     $err_msg .= "The first name of the employee must be alphanumeric.\\n";
 }
 if (v::not(v::alnum("-.,()'"))->validate($form_data['emp_lname'])) {
     $err_msg .= "The last name of the employee must be alphanumeric.\\n";
 }
 //if(v::not(v::alnum("-.,()'"))->validate($form_data['account_number'])) { $err_msg .= "The account number must be alphanumeric.\\n"; }
 // Phone
 if (v::not(v::phone())->validate($form_data['requester_phone'])) {
     $err_msg .= "Your phone number is not valid: " . $form_data['requester_phone'] . "\\n";
 }
 if (v::not(v::phone())->validate($form_data['dept_phone'])) {
     $err_msg .= "The department phone number is not valid: " . $form_data['dept_phone'] . "\\n";
 }
 // Date or Time - should not be in future
 if (v::not(v::date('Y-m-d')->max('today'))->validate($mysql_start_date)) {
     $err_msg .= "The start date is invalid: " . $start_date . "\\n";
 }
 if (v::not(v::date('Y-m-d')->max('today'))->validate($mysql_end_date)) {
     $err_msg .= "The end date is invalid: " . $end_date . "\\n";
 }
 // ========================================================================================
 // DATA PASSED VALIDATION - INSERT INTO DB AND SEND EMAILS
 // ========================================================================================
 if ($err_msg == '') {
     // ========================================================================================
     // GET BUSINESS MANAGER
開發者ID:URFacilities,項目名稱:form_additional_pay,代碼行數:31,代碼來源:process_request.php

示例5: createRecepientAction

 public function createRecepientAction()
 {
     $name = $this->app->request->post('name');
     $email = $this->app->request->post('email');
     $phone_number = $this->app->request->post('phone_number');
     $rules = array('name' => v::string()->notEmpty()->setName('name'), 'email' => v::email()->notEmpty()->setName('email'), 'phone_number' => v::phone()->setName('phone_number'));
     $data = $this->app->request->post();
     $message = array('type' => 'success', 'text' => 'Successfully added recepient');
     foreach ($data as $key => $value) {
         try {
             $rules[$key]->check($value);
         } catch (\InvalidArgumentException $e) {
             $message = array('type' => 'error', 'text' => $e->getMainMessage());
             break;
         }
     }
     if ($message['type'] == 'success') {
         $recepient = R::dispense('recepients');
         $recepient->name = $name;
         $recepient->email = $email;
         $recepient->phone_number = $phone_number;
         R::store($recepient);
     }
     $this->app->flash('message', $message);
     $this->app->redirect('/recepients/new');
 }
開發者ID:anchetaWern,項目名稱:naughtyfire,代碼行數:26,代碼來源:Home.php


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