Closed
Description
$data = [1,3,4];
$schema = [
"type" => "array",
"items" => [
"type" => "string",
"minLength" => 5,
],
'minItmes' => 1,
];
// Validate
$validator = new JsonSchema\Validator();
$validator->check($data, (object)$schema );
if ($validator->isValid()) {
echo "The supplied JSON validates against the schema.\n";
} else {
echo "JSON does not validate. Violations:\n";
foreach ($validator->getErrors() as $error) {
echo sprintf("[%s] %s\n", $error['property'], $error['message']);
}
}
//output
//The supplied JSON validates against the schema.
test by PHP5.6
Metadata
Metadata
Assignees
Labels
No labels