Example #1
0
 /**
  * Run the rule
  *
  * @return void
  * @author Justin Palmer
  **/
 public function run()
 {
     $boolean = parent::run();
     if ($boolean) {
         //Split the date into an array via dashes.
         $date = split('-', $this->value);
         //use the php checkdate function to see if the date is valid.
         if (!checkdate($date['1'], $date['2'], $date['0'])) {
             $boolean = FALSE;
         }
     }
     return $boolean;
 }
Example #2
0
 /**
  * constructor
  *
  * @return NameRule
  * @author Justin Palmer
  **/
 public function __construct($message = '%s is an invalid email address.')
 {
     parent::__construct("/^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)\$/", $message);
 }
Example #3
0
 /**
  * constructor
  *
  * @return AlphaExtraRule
  * @author Justin Palmer
  **/
 public function __construct($message = '%s should be a valid web address.')
 {
     $preg = "/^((http|https|ftp):\\/\\/(www\\.)?|www\\.)[a-zA-Z0-9\\_\\-]+\\.([a-zA-Z]{2,4}|[a-zA-Z]{2}\\.[a-zA-Z]{2})(\\/[a-zA-Z0-9\\-\\._\\?\\&=,'\\+%\$#~]*)*\$/";
     parent::__construct($preg, $message);
 }
Example #4
0
 /**
  * constructor
  *
  * @return NameRule
  * @author Justin Palmer
  **/
 public function __construct($message = '%s should be in the format: ##.##')
 {
     parent::__construct("/^([0-9]+.[0-9]{2})\$/", $message);
 }
Example #5
0
 /**
  * constructor
  *
  * @return AlphaExtraRule
  * @author Justin Palmer
  **/
 public function __construct($extra = '', $message = '%s should only include lowercase and capital letters.')
 {
     $preg = '/^([0-9' . $extra . '])+$/';
     parent::__construct($preg, $message);
 }
Example #6
0
 /**
  * constructor
  *
  * @return NameRule
  * @author Justin Palmer
  **/
 public function __construct($message = '%s should be in the format: ##-####### OR #########.')
 {
     parent::__construct("/^(\\d{2})\\-?(\\d{7})\$/", $message);
 }
Example #7
0
 /**
  * constructor
  *
  * @return NameRule
  * @author Justin Palmer
  **/
 public function __construct($message = '%s should be in the format: ###-###-####')
 {
     parent::__construct("/^([0-9]){3}(\\s|-)([0-9]){3}(-|\\s)([0-9]){4}\$/", $message);
 }
 /**
  * constructor
  *
  * @return NameRule
  * @author Justin Palmer
  **/
 public function __construct($message = '%s is not valid.')
 {
     parent::__construct("/^([0-9]){1,5}\\s?([0-9]){1,5}\\s?([0-9 \\-]){2,15}\$/", $message);
 }