public function testYouCanGetTheMessengerFromTheProcessor()
 {
     $obj = new ValidationProcessor(function ($value, Messenger $messenger) {
         $messenger->add(new StringType('foo bar'));
         return false;
     });
     $this->assertFalse($obj->validate('foo'));
     $messenger = $obj->getMessenger();
     $this->assertEquals('foo bar', $messenger->implode());
 }
Exemplo n.º 2
0
        {
            "d": "jim",
            "e": "EC1V 7DA"
        },
        {
            "d": "maggie",
            "e": "LE4 4HB"
        },
        {
            "d": "sue",
            "e": "SW17 9JR"
        }
    ],
    "f": [
        "*****@*****.**",
        "*****@*****.**"
    ]
}
EOT;
$validator = new ValidationProcessor($requiredValidator);
$validator->add($optionalValidator);
$test1 = $validator->validate(json_decode($json1));
echo 'Test 1: ' . ($test1 ? 'Value is valid' : 'Value is invalid') . PHP_EOL;
if (!$test1) {
    var_dump($validator->getMessenger()->implode());
}
$test2 = $validator->validate(json_decode($json2));
echo 'Test 2: ' . ($test2 ? 'Value is valid' : 'Value is invalid') . PHP_EOL;
if (!$test2) {
    var_dump($validator->getMessenger()->implode());
}