Data Validation: What you need to know

Data Validation: What you need to know

Created
Aug 11, 2021 8:06 AM
Tags
BlueprintsProject Management

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

icon

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

icon

If you end up finding this article useful — spread the word!

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. image
  4. Within the newly opened Pick Parent Class find and select the EditorValidorBase class.
  5. image

How to setup 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
  3. image
  4. Within the CanValidateAsset function, drag from In Asset and cast to the texture class
    1. You will want to utilize the pure case. To change from a Impure Cast to a Pure Cast, simply Right Click on the Impure Cast → Convert to pure cast
    2. image
  5. Within the Functions section, override the ValidateLoadedAsset function
  6. image
  7. Check if the Object Name starts with the Prefix T_.
    1. If it does, utilize the Asset Passes function to state that the Asset has passed.
    2. If it doesn't, utilize the Asset Fails function to state that the Asset did not pass and provide a reason.
    3. Provide a Return Node at the end of each argument with the correct Return Value
    4. image

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
image

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
image

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 a Editor Validator blueprint.

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

In the example above, I casted 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 a 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.

image

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.

image

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.

image

Resources

icon

Thank you for reading!

My goal with Unreal Directive is to provide an extremely useful and easy to understand resource for Unreal Engine developers across all skill levels. Therefore, if you have found this article useful, spread the word! Please share it with your developer friends and peers. If you have a suggestion, or have come across an issue with the article, please message me via Twitter or via email.

Thank you,