decoder2: fix number decoding and improve errors (#25015)

This commit is contained in:
Larsimusrex 2025-08-01 05:56:39 +02:00 committed by GitHub
parent c49b9da04e
commit f03d800800
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 552 additions and 225 deletions

View file

@ -90,8 +90,12 @@ fn test_required_attribute() {
mut has_error := false
json.decode[StruWithRequiredAttribute]('{"name": "hola", "a": 2, "b": 3}') or {
if err is json.JsonDecodeError {
assert err.line == 1
assert err.character == 31
assert err.message == 'Data: missing required field `skip_and_required`'
}
has_error = true
assert err.msg() == 'missing required field `skip_and_required`'
}
assert has_error, '`required` attribute not working. It should have failed'