On Tue, Jun 16, 2026 at 9:20 AM Kent Watsen <[email protected]> wrote:
> How does validation work if a union has multiple leafref/instance-identifier
> types with default "require-instance true"? For instance:
>
> typedef foo {
> type leafref {
> path "/widgets/name";
> require-instance true;
> }
> }
>
> typedef bar {
> type instance-identifier {
> require-instance true;
> }
> }
>
> leaf baz {
> type union {
> type foo;
> type bar;
> }
> }
>
>
>
> The general validation approach is to step thru the various union types
> until first match or no match. But when there are multiple "require-instance
> true" types, will validation succeed only if all match?
>
>
The 'require-instance' stmt is just another constraint, conceptually the
same as 'range' or 'pattern'.
All constraints must pass or keep going.
The validation processing text needs work (maybe in YANG 2)
https://github.com/netmod-wg/yang-next/issues/72
https://github.com/netmod-wg/yang-next/issues/157
sec 9.12:
When
interpreting an XML encoding, a value is validated consecutively
against each member type, in the order they are specified in the
"type" statement, until a match is found. The type that matched will
be the type of the value for the node that was validated, and the
encoding is interpreted according to the rules for that type.
1) The behavior is XML-specific.
The JSON behavior is completely different.
https://datatracker.ietf.org/doc/html/rfc7951#section-6.10
IMO it is wrong to have different YANG behavior based on protocol message
encoding.
It doesn't always work, especially after data is in a datastore.
There is a design assumption that the validation code is connected to the
XML or JSON parsing code.
2) Need to define the behavior if a member base type is also 'union'
The procedure is repeated for the member type (as many levels as needed),
processing the
member types in order. Maybe this is obvious and does not need to be
mentioned.
Andy
> _______________________________________________
> netmod mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
>
_______________________________________________
netmod mailing list -- [email protected]
To unsubscribe send an email to [email protected]