本文整理匯總了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;
}
示例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;
}
}
示例3: phone
/**
* 檢測手機號碼是否正確
*
* @param string $value 手機號碼
* @return bool
*/
public static function phone($value)
{
return Validator::phone()->validate($value);
}
示例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
示例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');
}