public function testThePatternWillFailIfRequiredKeyDoesNotExist() { $sut = new HasTypeMap(['foo' => 'string']); $this->assertFalse($sut->isValid([])); $this->assertEquals('Value key:foo does not exist: Value has invalid type map', implode(': ', $sut->getMessages())); }
"b": false, "c": [ { "d": "fred", "e": "NN10 6HB" }, { "d": "jim", "e": "EC1V 7DA" }, { "d": "maggie", "e": "LE4 4HB" }, { "d": "sue", "e": "SW17 9JR" } ], "f": [ "*****@*****.**", "*****@*****.**" ] } EOT; $value = json_decode($json); $test = $validator->isValid($value); echo $test ? 'Value is valid' : 'Value is invalid'; if (!$test) { var_dump($validator->getMessages()); }