コード例 #1
0
 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()));
 }
コード例 #2
0
ファイル: has-type-map.php プロジェクト: chippyash/validation
    "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());
}