Pop\Validator\Alpha::evaluate PHP Method

evaluate() public method

Method to evaluate the validator
public evaluate ( mixed $input = null ) : boolean
$input mixed
return boolean
    public function evaluate($input = null)
    {
        // Set the input, if passed
        if (null !== $input) {
            $this->input = $input;
        }
        // Set the default message
        if (null === $this->defaultMessage) {
            if ($this->condition) {
                $this->defaultMessage = I18n::factory()->__('The value must only contain characters of the alphabet.');
            } else {
                $this->defaultMessage = I18n::factory()->__('The value must contain characters not in the alphabet.');
            }
        }
        // Evaluate the input against the validator
        if (preg_match('/^[a-zA-Z]+$/', $this->input) == $this->condition) {
            $this->result = true;
        } else {
            $this->result = false;
        }
        return $this->result;
    }

Usage Example

コード例 #1
0
ファイル: StringTest.php プロジェクト: nicksagona/PopPHP
 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));
 }
All Usage Examples Of Pop\Validator\Alpha::evaluate