Guarding
Learn how the Guard validation framework works in Validatox and how it can deliver useful utilities for your project
Guarding can take a bit of time depending on the size of the project, the number of scenes and the number of assets. For this reason it is possible to create multiple GuardValidators and assign them as default in the Hub window in order to be able to validate only interested part of the project during different development iterations.
Introduction
The Guard validation framework allows to perform validation on references of any script in the project inheriting from UnityEngine.Object
.
Guard validation is performed by the GuardValidator. Validatox provides a default GuardValidator that is located in the package Editor folder.
It is recommended to always override the default GuardValidator by creating a new one in the Assets/Editor folder in order to be able to edit its properties and adapt it to the project needs.
Override default GuardValidator
In order to override the custom GuardValidator, create a new one in the Asset/Editor folder by selecting: Create -> Validatox -> Guard validator
GuardAttribute
The Guard
attribute is the marker that allows the GuardValidator to identify and validate the field the attribute is associated to.
When marking a field with the attribute, it is assured that when running the GuardValidator, it will identify the field and check its value, in order to validate its reference status.
The prefab field is marked with the Guard attribute and is serialized in the inspector. When validating, the GuardAttribute will verify that the field is populated.
Note that the GuardAttribute works only with reference type fields.
Last updated