Skip to content
This repository has been archived by the owner on Oct 26, 2023. It is now read-only.

Commit

Permalink
Fixed schema validation for defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
siad007 authored and danez committed May 5, 2020
1 parent 9d4a7db commit 590dd90
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/avro/schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,11 @@ public static function is_valid_datum($expected_schema, $datum)
case self::REQUEST_SCHEMA:
if (is_array($datum))
{
foreach ($expected_schema->fields() as $field)
if (!array_key_exists($field->name(), $datum) || !self::is_valid_datum($field->type(), $datum[$field->name()]))
return false;
foreach ($expected_schema->fields() as $field) {
$value = isset($datum[$field->name()]) ? $datum[$field->name()] : $field->default_value();
if (!self::is_valid_datum($field->type(), $value))
return false;
}
return true;
}
return false;
Expand Down

0 comments on commit 590dd90

Please sign in to comment.