Handle [] leniently in constructor binding

See gh-34305
This commit is contained in:
rstoyanchev
2025-02-10 17:41:05 +00:00
parent 9797bc0acd
commit 4591a67641
2 changed files with 38 additions and 12 deletions

View File

@@ -188,6 +188,17 @@ class DataBinderConstructTests {
assertThat(target.integerList()).containsExactly(1, 2);
}
@Test
void simpleListBindingEmptyBrackets() {
MapValueResolver valueResolver = new MapValueResolver(Map.of("integerList[]", "1"));
DataBinder binder = initDataBinder(IntegerListRecord.class);
binder.construct(valueResolver);
IntegerListRecord target = getTarget(binder);
assertThat(target.integerList()).containsExactly(1);
}
@Test
void simpleMapBinding() {
MapValueResolver valueResolver = new MapValueResolver(Map.of("integerMap[a]", "1", "integerMap[b]", "2"));