Data Validation: What you need to know

Data Validation is an important aspect within Unreal Engine development. It easily allows developers to audit assets with their own custom-scripted rulesets.

Data Validation: What you need to know

Data Validation is an important aspect of Unreal Engine development. It easily allows developers to audit assets with their custom-scripted rulesets. For example, developers can utilize Data Validation to verify that their project conforms to naming conventions, enforce performance budgets, and more.

Important

  • Requires the Data Validation plugin to be enabled
  • Newly created rule sets require an Editor restart to take effect.

Want to discuss this article, Unreal Engine, or media in general? Head on over to the official Unreal Directive Discord server! We're looking to foster a helpful and fun community!


How to create a new Data Validator

Thankfully, creating a custom Data Validator can be done in a few simple steps —

  1. Right-click inside of the Content Browser
  2. Within the newly opened Command List, navigate to the Editor Utilities → Editor Utility Blueprint

3. Within the newly opened Pick Parent Class - find and select the EditorValidorBase class.


How to set up a custom Data Validator

I will demonstrate how to create a Data Validator to validate that textures conform to Allar's Style Guide.

  1. Open up a newly created validator blueprint
  2. Within the Function section, override the CanValidateAsset function
  1. Within the CanValidateAsset function, drag from In Asset and cast to the texture class
    • You will want to utilize the pure case. To change from an Impure Cast to a Pure Cast, simply Right Click on the Impure Cast → Convert to pure cast

4. Within the Functions section, override the ValidateLoadedAsset function

  1. Check if the Object Name starts with the Prefix T_.
    • If it does, utilize the Asset Passes function to state that the Asset has passed.
    • If it doesn't, utilize the Asset Fails function to state that the Asset did not pass and provide a reason.
    • Provide a Return Node at the end of each argument with the correct Return Value

How to validate an asset

Here, I will go over multiple methods on how to validate assets.

Method 1 - Validation via command menu

  • Within the Content Browser, find an asset that you want to validate.
  • One or multiple assets can be selected
    • On that asset —- Right Click -> Asset Actions -> Validate Assets
  • This will run the validator, with the results appearing in the Message Log

Method 2 - Validate on save

This method validates assets when they are saved or cooked. This method is ideal as it makes sure that assets don't slip through the cracks and are not validated.

While this method is usually enabled by default, I'll provide instructions on how to enable it.

  1. Open the Editor Preferences Window — Edit -> Editor Preferences
  2. Navigate to — Advanced -> Data Validation
  3. Enable Validate On Save

Function Overview

Here's a more in-depth explanation of the functions you will be using within the Data Validators.

CanValidateAsset

One of the two functions that can be overridden within an Editor Validator blueprint.

This function is used to determine what asset type should be validated using that validator blueprint.

In the example above, I cast to the Texture asset type using a Pure Case. The same method can be utilized for any type of asset within Unreal Engine, including custom-created ones.

ValidateLoadedAsset

One of the two functions that can be overridden within an Editor Validator blueprint.

This function is used to define the validation (pass or fail) argument.

It's imperative to utilize the Asset Passes and Asset Fails functions, along with making sure each argument path ends in a Return Node with the correct Return Value.

Asset Passes

One of the three functions that are used within the ValidateLoadedAsset overridden function.

This function is used to state that the validating asset passes the provided argument.

Asset Fails

One of the three functions that are used within the ValidateLoadedAsset overridden function.

This function is used to state that the validating asset does NOT pass the provided argument. It is ideal to provide a detailed message on why the asset did not pass.

Asset Warning

One of the three functions that are used within the ValidateLoadedAsset overridden function.

This function is used to provide a detailed warning message when the validating mesh doesn't necessarily pass or fail the provided argument.


Additional Resources

Data Validation
Developers can extend this system to validate assets with custom-scripted rulesets.

If you like the content and it has helped you, please consider supporting the development of the Unreal Directive.