corenova / yang-js

YANG parser and composer
Apache License 2.0
56 stars 18 forks source link

The empty Built-In Type #51

Closed vcshox closed 7 years ago

vcshox commented 7 years ago

According to RFC7951#6.9 [null] should be the valid value of an empty type data. However when I evaluated a JSON value with [null], the following error was thrown:

ExpressionError: [module(example-sports)/leaf(leaf_empty)] predicate validation error during apply

sekur commented 7 years ago

You're right. I should increase support to consider RFC7951 inside yang-js.

However, it's a bit of a strange encoding since a leaf isn't supposed to contain an array data entry. Since JS natively supports undefined and null as separate primitives it doesn't seem logical to not have used a simple null to designate an empty type in this case.

vcshox commented 7 years ago

@saintkepha

Yeah, [null] looks strange at first glance. Any plan to enhance this part?

Thank you.

sekur commented 7 years ago

Yes - planning an update for this in a couple of days

sekur commented 7 years ago

@vcshox - I've also published 0.16.23 which includes this fix

vcshox commented 7 years ago

@saintkepha

Thanks a lot!