示例#1
0
 public static function equalToField($field)
 {
     return function ($value, $params) use($field) {
         if (!isset($value) || $value === '') {
             return;
         }
         if (!\Validator\LIVR\Util::isStringOrNumber($value)) {
             return 'FORMAT_ERROR';
         }
         if ($value != $params[$field]) {
             return 'FIELDS_NOT_EQUAL';
         }
         return;
     };
 }
示例#2
0
 public static function like($re)
 {
     $re = '/' . $re . '/';
     if (func_num_args() == 3) {
         #Passed regexp flag
         $flags = func_get_arg(1);
         if ($flags && $flags != 'i') {
             throw new Exception("Only 'i' regexp flag supported, but '" . $flags . "' passed");
         }
         $re .= $flags;
     }
     return function ($value) use($re) {
         if (!isset($value) or $value === '') {
             return;
         }
         if (!\Validator\LIVR\Util::isStringOrNumber($value)) {
             return 'FORMAT_ERROR';
         }
         if (!preg_match($re, $value)) {
             return 'WRONG_FORMAT';
         }
         return;
     };
 }
示例#3
0
 public static function numberBetween($minNumer, $maxNumer)
 {
     return function ($value) use($minNumer, $maxNumer) {
         if (!isset($value) or $value === '') {
             return;
         }
         if (!\Validator\LIVR\Util::isStringOrNumber($value)) {
             return 'FORMAT_ERROR';
         }
         if ($value < $minNumer) {
             return 'TOO_LOW';
         }
         if ($value > $maxNumer) {
             return 'TOO_HIGH';
         }
         return;
     };
 }