Respect\Validation\Rules\Type::validate PHP Method

validate() public method

public validate ( $input )
    public function validate($input)
    {
        $lowerType = mb_strtolower($this->type);
        if ('callable' === $lowerType) {
            return is_callable($input);
        }
        return $this->availableTypes[$lowerType] === gettype($input);
    }

Usage Example

Example #1
0
 /**
  * @dataProvider providerForInvalidType
  */
 public function testShouldNotValidateInvalidTypes($type, $input)
 {
     $rule = new Type($type);
     $this->assertFalse($rule->validate($input));
 }