fix: accept JSON string defaults for decimal fields in union (#580)

* fix: accept JSON string defaults for decimal fields in union

Per Avro 1.12.0 Specification, §"Complex Types / Records", the JSON
encoding of a `bytes` field's default value is a string whose codepoints
0-255 map to byte values 0-255 (e.g. `"\u00FF"`). The same section
specifies that a union-typed field's default must correspond to the
first schema that matches in the union.

`decimal` is defined as a logical type over `bytes`, so this rule
transitively applies: a nullable decimal field expressed as
`[{bytes, logicalType: decimal}, null]` with a JSON string default
requires `resolve_decimal` to accept `Value::String` when validating
defaults at schema parse time. Before this change the parser rejected
such schemas with `GetDefaultUnion(Decimal, String)`, even though
Java and Python Avro accept them.

The added arm walks the string's codepoints, rejecting any above
0xFF, and returns a `Value::Decimal`. The precision check is skipped
because the spec does not require a default's byte length to cover
the declared precision — it only requires a valid `bytes` value.
Wire-level decoded records always reach `resolve_decimal` as
`Value::Bytes`, so this arm is exclusively a default-validation path.

Tests cover `\u0000`, a full 0..=255 round-trip, codepoints > 0xFF
being rejected, and end-to-end parsing of a nullable decimal record
schema.

* fix: review comments

* chore: Fix test output

---------

Co-authored-by: Laurent Valdes <laurent@lapoule.dev>
Co-authored-by: Vyacheslav Mayorov <v.majorov@picodata.io>
Co-authored-by: Kriskras99 <github@kriskras99.nl>
2 files changed