Using The Validator In Your Custom Pipeline

To run the Odin Validator in your custom pipeline, you need a reference to the validation session you want to run. You can get a reference to the current validation session by accessing ValidationSession.MainValidationSession. If you want to access a different one, you can do so by retrieving a validation profile from your project's asset folder.

var profile = AssetDatabase.LoadAssetAtPath<ValidationProfile>("Assets/Path/To/Validation/Profile.asset");

If you want to create a new validation profile for this purpose, you can do so by clicking on the profile selection button in the upper left corner of the validator window.

To run the validator, simply call the ValidateEverythingEnumerator method on a given validation session and enumerate the results.

var session = ValidationSession.MainValidationSession;

foreach (var result in session.ValidateEverythingEnumerator())
{
    if (result.ResultType == ValidationResultType.Error)
    {
        // You have a validation error, do something.
        // [...]
    }
}

or if you're accessing it via a validation profile

var profile = AssetDatabase.LoadAssetAtPath<ValidationProfile>("Assets/Path/To/Validation/Profile.asset");

using (var session = new ValidationSession(profile))
{
    foreach (var result in session.ValidateEverythingEnumerator())
    {
        if (result.ResultType == ValidationResultType.Error)
        {
        	// You have a validation error, do something.
        	// [...]
        }
    }
}

The parameters of the ValidateEverythingEnumerator will let you control if you want to validate closed scenes and if you want to show a progress bar.

If you want to create a validation report as part of your custom pipeline, you can do so by calling ToJson or ToHtml on any validation session.

var json = ValidationSession.MainValidationSession.ToJson();
var html = ValidationSession.MainValidationSession.ToHtml();

That's it!