Esempio n. 1
0
 /**
  * (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;
 }
Esempio n. 2
0
 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;
     }
 }
Esempio n. 3
0
 /**
  * 检测手机号码是否正确
  *
  * @param  string $value 手机号码
  * @return bool
  */
 public static function phone($value)
 {
     return Validator::phone()->validate($value);
 }
 }
 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
Esempio n. 5
0
 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');
 }