Provide options based on Order of configurations

I have the following data model. Is it possible to provide options as below??

list list-of-names {
   key "name";
   ordered-by user;

  leaf name {
  	type string;
  }

  leaf next-name {
  	typedef leafref "../name";
  }  

  leaf prev-name {
  	typedef leafref "../name";
  }

}


list-of-names name a
list-of-names name b
list-of-names name c
list-of-names name d 


**Need to provide following way of options to the user.**


list-of-names name a next-name ?  <-- Should show only b,c,d
list-of-names name b next-name ?  <-- Should show only c,d
list-of-names name c next-name ?  <-- Should show only d
list-of-names name d next-name ?  <-- Should show nothing..As nothing is configured after d
 
list-of-names name d prev-name ?  <-- Should show c,b,a
list-of-names name c prev-name ?  <-- Should show b,a
list-of-names name b prev-name ?  <-- Should show a

I don’t think this is possible to achieve without using a Tab completion callback and a validation callback to make sure the values for next and prev are valid.

Hi Nabil,

Thanks for the reply, But tab completion applies only specific NorthBound API (CLI)… We want to cover all the NorthBound api’s. Instead of writing individually, is there any better approach for these issues ??

When you say: “Should only show” this means CLI.

I don’t think this is possible to apply in other NBI.
A design like this is complicated. Are you trying to model a doubly linked list?

What happens if you want to delete in the middle?

In any case, validation callbacks can be used to validate these configurations regardless of the NB interface.

I don’t think you can express this in a must statement either.

For validation I recommend a validation callback, your application can build the list internally and be able to know what values can be set.