Permalink
Browse files

Making "type" and "properties" attributes optional, per draft 3 spec …

…(Last paragraph of section 5: "A JSON Schema object may have any of the following properties, called schema attributes (all attributes are optional)"
  • Loading branch information...
1 parent cbd96e6 commit 17781022b2b58aa3b3a1c5363aa9a3b1a6b390e6 Curtis Farnham committed Feb 26, 2012
Showing with 7 additions and 4 deletions.
  1. +7 −4 src/Json/Validator.php
View
@@ -144,7 +144,8 @@ protected function validateProperties($entity, $schema, $entityName)
$properties = get_object_vars($entity);
if (!isset($schema->properties)) {
- throw new SchemaException(sprintf('No properties defined for [%s]', $entityName));
+ return $this;
+ //throw new SchemaException(sprintf('No properties defined for [%s]', $entityName));
}
// Check defined properties
@@ -183,11 +184,13 @@ protected function validateProperties($entity, $schema, $entityName)
*/
protected function validateType($entity, $schema, $entityName)
{
- if (!isset($schema->type)) {
- throw new ValidationException(sprintf('No type given for [%s]', $entityName));
+ if (isset($schema->type)) {
+ $types = $schema->type;
+ } else {
+ $types = 'any';
+ //throw new ValidationException(sprintf('No type given for [%s]', $entityName));
}
- $types = $schema->type;
if (!is_array($types)) {
$types = array($types);
}

0 comments on commit 1778102

Please sign in to comment.