[YANGTOOLS-1545] Min/max-elements are not enforced for wrapped elements in container Created: 02/Oct/23 Updated: 06/Oct/23 |
|
| Status: | Open |
| Project: | yangtools |
| Component/s: | None |
| Affects Version/s: | 11.0.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Medium |
| Reporter: | Peter Suna | Assignee: | Ivan Hrasko |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | pt | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Description |
|
Currently, it is possible to create a list/leaf-list with min-elements and max-element violations if those elements are wrapped with a container in the payload. For example in this model:
module test-container-childs {
namespace "http://example.com/test/container/child";
prefix "tcc";
revision 2023-09-28;
container root-container {
container nested-container {
list mandatory-list {
min-elements 1;
max-elements 3;
key id;
leaf id {
type uint32;
}
}
}
}
}
It is allowed to create 0 list resources or more than 3, if the list `mandatory-list` is wrapped with "nested-container" in the payload:
{
"nested-container": {
"mandatory-list": []
}
}
The same issue is present for the leaf-list element.
This issue was already reported before, and resolved: |
| Comments |
| Comment by Robert Varga [ 03/Oct/23 ] |
|
So "create" as in normalized node structure? |
| Comment by Peter Suna [ 04/Oct/23 ] |
|
It is possible to write into the task model using the method.
ImmutableContainerNode{
name=(http://example.com/test/container/child?revision=2023-09-28)nested-container,
body=[
ImmutableMapNode{
name=(http://example.com/test/container/child?revision=2023-09-28)mandatory-list,
body=[
ImmutableMapEntryNode{
name=(http://example.com/test/container/child?revision=2023-09-28)mandatory-list[{(http://example.com/test/container/child?revision=2023-09-28)id=1}],
body=[
ImmutableLeafNode{
name=(http://example.com/test/container/child?revision=2023-09-28)id,
body=1
}
]
},
ImmutableMapEntryNode{
name=(http://example.com/test/container/child?revision=2023-09-28)mandatory-list[{(http://example.com/test/container/child?revision=2023-09-28)id=2}],
body=[
ImmutableLeafNode{
name=(http://example.com/test/container/child?revision=2023-09-28)id,
body=2
}
]
},
ImmutableMapEntryNode{
name=(http://example.com/test/container/child?revision=2023-09-28)mandatory-list[{(http://example.com/test/container/child?revision=2023-09-28)id=3}],
body=[
ImmutableLeafNode{
name=(http://example.com/test/container/child?revision=2023-09-28)id,
body=3
}
]
},
ImmutableMapEntryNode{
name=(http://example.com/test/container/child?revision=2023-09-28)mandatory-list[{(http://example.com/test/container/child?revision=2023-09-28)id=4}],
body=[
ImmutableLeafNode{
name=(http://example.com/test/container/child?revision=2023-09-28)id,
body=4
}
]
}
]
}
]
}
|