예제 #1
0
 /**
  * @param $newMobileNum
  * @return null
  * @throws Exception
  * @internal param $db
  */
 public static function validateMobileNumber($newMobileNum)
 {
     if (empty($newMobileNum) === true) {
         return null;
         // no mobilenumber
     }
     if (!preg_match('/^[0-9]{10}$/', $newMobileNum)) {
         throw new Exception('Mobile number should contain only digits of total length 10');
     }
     if (UserFetcher::existsMobileNum($newMobileNum)) {
         throw new Exception("Mobile entered number already exists in database.");
         // the array of errors messages
     }
     return $newMobileNum;
 }