Beispiel #1
0
 public function testMatch()
 {
     $value = 'super-09';
     $this->assertTrue(v::match($value, '/[a-z0-9-]+/i'));
     $value = '#1asklajd.12jaxax';
     $this->assertFalse(v::match($value, '/^[a-z0-9-]+$/i'));
 }
Beispiel #2
0
    return v::min($value, $min) && v::max($value, $max);
}, 'date' => function ($value) {
    $time = strtotime($value);
    if (!$time) {
        return false;
    }
    $year = date('Y', $time);
    $month = date('m', $time);
    $day = date('d', $time);
    return checkdate($month, $day, $year);
}, 'different' => function ($value, $other) {
    return $value !== $other;
}, 'email' => function ($value) {
    return filter_var($value, FILTER_VALIDATE_EMAIL) !== false;
}, 'filename' => function ($value) {
    return v::match($value, '/^[a-z0-9@._-]+$/i') && v::min($value, 2);
}, 'in' => function ($value, $in) {
    return in_array($value, $in, true);
}, 'integer' => function ($value) {
    return filter_var($value, FILTER_VALIDATE_INT) !== false;
}, 'ip' => function ($value) {
    return filter_var($value, FILTER_VALIDATE_IP) !== false;
}, 'match' => function ($value, $preg) {
    return preg_match($preg, $value) > 0;
}, 'max' => function ($value, $max) {
    return size($value) <= $max;
}, 'min' => function ($value, $min) {
    return size($value) >= $min;
}, 'notIn' => function ($value, $notIn) {
    return !v::in($value, $notIn);
}, 'num' => function ($value) {