Feature Request - Expose means of running validation code for Odin Validator attributes

Issue #705 resolved
Ryan George created an issue

I have a custom build tool that validates a configuration based on the settings specified in a build configuration. Within this tool, I have an Odin Validator-like “live” validator that look over the config and return a list of error strings that are reported to the user:

I realized this morning that I’ve been duplicating the functionality of [Required] for a lot of fields in our config. What I would like to be able to do from my code is:

  1. Enumerate all the fields in a C# object that have Odin Validator-relevant attributes

    1. We have code to do this, but obviously y’all do too
  2. Perform validation on those fields using Odin Validator

    1. This would include not only [Required] but also things like [ValidateInput(…)] and any other custom validators/attributes within the Odin ecosystem
  3. Return a list of validation errors that I can then feed back into my errors list that’s displayed to the user.

I do realize that Validator would still work properly within my editor window, but the UX for this tool is that all errors appear in that little side bar, especially because some settings are hidden within a foldout group.


Comments (2)

  1. Tor Esa Vestergaard

    After some discussion with Ryan on Discord, this feature is actually already implemented for UnityEngine.Object-derived types in 2.1 via ValidationRunner.ValidateUnityObjectRecursively, and made far more easy for all kinds of values in 3.0, using either PropertyTree directly, or using ValidationRunner.ValidateObjectRecursively.

  2. Log in to comment