Better Validation

uurha

Arcueid

Posted on July 23, 2023

Better Validation

The Better Validation package provides attributes to perform validation in scenes and the whole project. Link to the project:

https://github.com/techno-dwarf-works/better-validation

Validation

To initiate validation, you can go to Toolbar > Better > Validation > Open Validation Window, or it may start automatically prior to building (validation before play mode will be available in the future).

Validation window

Settings

If you wish to disable automatic pre-build validation or change the logging level, you can open the settings at Toolbar > Better > Validation > Highlight settings or Edit > Project Settings > Better > Validation.

Settings window

Available Attributes

The available attributes completely cover all the needs of the modern development process. But if you need more, just add an issue on GitHub, and I'll get back to you.

  1. NotNull: Fails if a UnityEngine.Object is null or has a missing reference.

  2. PrefabField: Inherits from NotNull and fails if the field references a scene object or an object context.

  3. SceneReference: Inherits from NotNull and fails if the field references a prefab in the Project.

  4. Find: Searches for a Component of Type provider in the constructor. It has additional settings:

    • ValidateIfFieldEmpty: Configures the search only if the field is null or missing.
    • RequireDirection: Configures the direction of the search.
  5. DataValidation: Validates data in the field using the provided method name. It only supports methods in the same class. The method can return one of the following types:

    • void: Validation will be called, but nothing will be displayed in the editor or the Validation Window.
    • bool: true represents a successful validation, while false will draw a default error in the editor and the Validation Window.
    • string: The returned string is regarded as a failed validation, while an empty string indicates success.

All attributes have a ValidationType that represents the importance of the validation result.

The plugin supports extensions through IBuildValidationStep and IValidationStep interfaces.

๐Ÿ’– ๐Ÿ’ช ๐Ÿ™… ๐Ÿšฉ
uurha
Arcueid

Posted on July 23, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

ยฉ TheLazy.dev

About