Leafref using multiple path with OR condition?

I have a sceneriao as below:

Orange {
name <> ; o1,o2,o3
}

Mango {
name<>; m1,m2,m3
}

Fruits {
name <>

leaf-list which {
type leafref {
path “Mango/name OR Orange/name” <<<-----
}
}

So basically “Fruits/which” should be able to refer to existing Oranges and Mangoes.

path “mango/name” works but multiple pathref’s not working.

Is there a way where I can make which refer to multiple paths?? using some or style condition.

Thanks

This is not possible. It’s not possible to have a leafref point to two different paths.

What you can do here is to have the type as a string with a must statement expressing that the value should exist in the Orange or Mango lists.

Or have a validation callback to validate the data.

Thanks Nabil,
That solves the issue or using only elements present in those 2 lists.
Leafref’s also generate help on typing tab/? to ease user to select elements from list. But replacing it with “must” is not generating. Is there a way to generate possible-completions to user still using “must” or other way?

Possible completions:
string [