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

Commit 590dd90

Browse files
siad007danez
authored andcommitted
Fixed schema validation for defaults
1 parent 9d4a7db commit 590dd90

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/avro/schema.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,9 +459,11 @@ public static function is_valid_datum($expected_schema, $datum)
459459
case self::REQUEST_SCHEMA:
460460
if (is_array($datum))
461461
{
462-
foreach ($expected_schema->fields() as $field)
463-
if (!array_key_exists($field->name(), $datum) || !self::is_valid_datum($field->type(), $datum[$field->name()]))
464-
return false;
462+
foreach ($expected_schema->fields() as $field) {
463+
$value = isset($datum[$field->name()]) ? $datum[$field->name()] : $field->default_value();
464+
if (!self::is_valid_datum($field->type(), $value))
465+
return false;
466+
}
465467
return true;
466468
}
467469
return false;

0 commit comments

Comments
 (0)