# Relationship validation

**URL:** <https://forum.aousd.org/t/relationship-validation/1209>\
**Category:** USD\
**Created:** [February 5, 2024, 9:50pm UTC](https://forum.aousd.org/t/relationship-validation/1209 "2024-02-05T21:50:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dhruvgovil](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.aousd.org/dhruvgovil/32/3_2.png) [@dhruvgovil](https://forum.aousd.org/u/dhruvgovil)\
**Post date:** [February 5, 2024, 9:50pm UTC](https://forum.aousd.org/t/relationship-validation/1209/1 "2024-02-05T21:50:45Z")

</div>

Is there any form of validation for relationship attributes? And on that same note, even if USD itself doesn’t validate, is there a way to express the restrictions?  
II think the answer is no to both, but I just wanted to check in case I missed something.

The kinds of restrictions I was thinking of are:

1. Type validation e.g I material binding should only point to Material prims etc…
2. Cycle checking to prevent cyclical relationships

It would also be good to know what we do when a cycle is encountered. Is that purely up to the consuming app/render delegate?

---

<div class="post-metadata">

**Author:** ![BigRoyNL](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.aousd.org/bigroynl/32/413_2.png) [@BigRoyNL](https://forum.aousd.org/u/BigRoyNL)\
**Post date:** [February 5, 2024, 10:38pm UTC](https://forum.aousd.org/t/relationship-validation/1209/2 "2024-02-05T22:38:59Z")

</div>

> [@dhruvgovil](#):
>
> Type validation e.g I material binding should only point to Material prims etc…

Don’t have a clear answer, but…

Isn’t it technically possible in USD to set up a binding to a material path that doesn’t actually exist? If so, at what level would you expect this type checking to occur? On the stage composing?

I had seen e.g. Render Settings with Render Product relationships being able to map a relationship target even to a Render Product does not exist anymore.

Also, I haven’t seen any typing around any `UsdRelationship` myself so I’m not sure if there’s even a registry that says they can only bind to material prims. (Aside of that, couldn’t they also bind to Collections?)

---

<div class="post-metadata">

**Author:** ![dhruvgovil](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.aousd.org/dhruvgovil/32/3_2.png) [@dhruvgovil](https://forum.aousd.org/u/dhruvgovil)\
**Post date:** [February 5, 2024, 10:53pm UTC](https://forum.aousd.org/t/relationship-validation/1209/3 "2024-02-05T22:53:50Z")

</div>

Yeah I was thinking it wouldn’t necessarily be at author/write time but could be some kind of utility function or option on an attribute writer. So you could still author dangling ones, but check resolution at different times

---

<div class="post-metadata">

**Author:** ![spiff](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.aousd.org/spiff/32/22_2.png) [@spiff](https://forum.aousd.org/u/spiff)\
**Post date:** [February 6, 2024, 12:44am UTC](https://forum.aousd.org/t/relationship-validation/1209/4 "2024-02-06T00:44:21Z")

</div>

Keep an eye out for our proposal on a general validation framework. We don’t want to generally do alot of validation within the core authoring code… and cycles aren’t _always_ a proscribed thing 🙂 though that one might make sense as a “general warning”…

---

<div class="post-metadata">

**Author:** ![dhruvgovil](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.aousd.org/dhruvgovil/32/3_2.png) [@dhruvgovil](https://forum.aousd.org/u/dhruvgovil)\
**Post date:** [February 6, 2024, 2:12am UTC](https://forum.aousd.org/t/relationship-validation/1209/5 "2024-02-06T02:12:42Z")

</div>

Oh nice. Something to look forward to

---

<div class="post-metadata">

**Author:** ![syoyo](https://avatars.discourse-cdn.com/v4/letter/s/5e9695/32.png) [@syoyo](https://forum.aousd.org/u/syoyo)\
**Post date:** [February 6, 2024, 1:40pm UTC](https://forum.aousd.org/t/relationship-validation/1209/6 "2024-02-06T13:40:25Z")

</div>

For cyclic checking of attribute connection, TinyUSDZ Tydra records visited property paths to detect it:

> <https://github.com/syoyo/tinyusdz/blob/1c1032414c7df3b38434ee1e77e7821f41eae647/src/tydra/scene-access.cc#L1740>

Same can be applied to Relationship resolution. As @spiff pointed out, validation should be done in surrounding framework, not in core part.
