Bluz\Validator\ValidatorBuilder::assert PHP Method

assert() public method

Assert
public assert ( mixed $input ) : boolean
$input mixed
return boolean
    public function assert($input)
    {
        if (!$this->validate($input)) {
            $exception = new ValidatorException();
            $exception->setErrors($this->getErrors());
            throw $exception;
        }
        return true;
    }

Usage Example

 /**
  * Setup multi builder for empty object
  * @expectedException \Bluz\Validator\Exception\ValidatorException
  */
 public function testValidatorBuilderForEmptySet()
 {
     $validator = new ValidatorBuilder();
     $validator->add('foo', Validator::required());
     $validator->add('bar', Validator::numeric());
     $this->assertFalse($validator->validate([]));
     $this->assertFalse($validator->assert([]));
 }