/** * @param string $name * @param Validator $validator * @return bool */ public function isPostParamValid($name, Validator $validator) { return $validator->isValid($this->request->get($name)); }
public function testCallback() { $validator = Validator::callbackFactory(function ($value) { return $value == 'bar'; }); $this->assertFalse($validator->isValid(0)); $this->assertFalse($validator->isValid('foobar')); $this->assertFalse($validator->isValid('foo')); $this->assertTrue($validator->isValid('bar')); }