Open gregorydemay opened 7 months ago
cddl = "0.9.4"
[0, [0]]
[0, 0]
Example
#[test] fn should_validate_nested_array() { let schema = r#"root = [0, 0]"#; let cbor_bytes = [0x82, 0x00, 0x00]; let result = cddl::validate_cbor_from_slice(schema, &cbor_bytes, None); assert!( //PASSES! result.is_ok(), "Validation of {:x?} failed: {:?}", cbor_bytes, result ); let schema = r#"root = [0, [0]]"#; let cbor_bytes = [0x82, 0x00, 0x81, 0x00]; let result = cddl::validate_cbor_from_slice(schema, &cbor_bytes, None); assert!( //FAILS! result.is_ok(), "Validation of {:x?} failed: {:?}", cbor_bytes, result ); }
The first assertion passes, while the second one returns the following error
Validation of [82, 0, 81, 0] failed: Err(Validation([ValidationError { reason: "expected array with length 1, got 2", cddl_location: "", cbor_location: "", is_multi_type_choice: false, is_multi_group_choice: false, is_group_to_choice_enum: false, type_group_name_entry: None }]))
Thanks for reporting @gregorydemay. This is going to take a little time for me to fix. The array validation logic I have implemented is a bit of a mess and doesn't properly validate nested arrays.
cddl = "0.9.4"
[0, [0]]
. Note that the not-nested schema[0, 0]
seems to work fine.Example
The first assertion passes, while the second one returns the following error