evaluate() публичный Метод

Method to evaluate the validator
public evaluate ( mixed $input = null ) : boolean
$input mixed
Результат boolean
Пример #1
0
 public function testEvaluateMessageFalse()
 {
     $v = new AlphaNumeric(null, 'This is alphanumeric', false);
     $this->assertEquals('This is alphanumeric', $v->getMessage());
     $this->assertFalse($v->evaluate('abcdef123'));
     $this->assertTrue($v->evaluate('123456$#@'));
 }
Пример #2
0
 public function testStringRandom()
 {
     $s = String::random(6);
     $this->assertEquals(6, strlen($s));
     $s = String::random(6, String::ALPHANUM, String::LOWER);
     $val = new Validator\AlphaNumeric();
     $this->assertTrue($val->evaluate($s));
     $s = String::random(6, String::ALPHA, String::UPPER);
     $val = new Validator\Alpha();
     $this->assertTrue($val->evaluate($s));
 }
Пример #3
0
<?php

require_once '../../bootstrap.php';
use Pop\Validator;
try {
    // Create an alphanumeric validator
    $val = new Validator\AlphaNumeric();
    $input = 'abcd1234';
    // Evaluate if the input value meets the rule or not
    if (!$val->evaluate($input)) {
        echo $val->getMessage();
    } else {
        echo 'The validator test passed. The string is alphanumeric.';
    }
} catch (\Exception $e) {
    echo $e->getMessage() . PHP_EOL . PHP_EOL;
}