Пример #1
0
 public function testSetTemplateWithMultipleValidatorsShouldUseTemplateAsFullMessage()
 {
     try {
         Validator::callback('is_string')->between(1, 2)->setTemplate('{{name}} is not tasty')->assert('something');
     } catch (NestedValidationExceptionInterface $e) {
         $this->assertEquals('\\-"something" is not tasty
\-"something" must be greater than 1', $e->getFullMessage());
     }
 }
Пример #2
0
 public function init()
 {
     $this->validator = v::attribute('name', v::string()->notEmpty())->attribute('email', v::email())->attribute('description', v::string()->length(5, 50))->attribute('age', v::callback('is_int')->between(0, 100))->attribute('nick', v::string()->alnum()->noWhitespace())->attribute('creditCard', v::numeric()->creditCard())->attribute('accountBalance', v::float())->attribute('banned', v::bool())->attribute('views', v::callback('is_int')->positive());
 }