A powerful validation plugin for Godot that catches errors before they reach
runtime. Validate scenes, nodes, and resources using a declarative, test-driven
approach. No @tool required!
See Godot Doctor in action:
You can download Godot Doctor directly from the Editor through the Asset Library.
Or, by manual installation:
- Download the source code .zip from the latest release.
- Copy the
addons/godot_doctorfolder to your project'saddons/directory - Enable the plugin in Project Settings > Plugins
- (Optional:) Adjust the settings asset in
addons/godot_doctor/settings.
- What is Godot Doctor?
- Why Use Godot Doctor?
- Syntax
- How It Works
- Examples
- Installation
- License
- Contributing, Bug Reports & Feature Requests
Godot Doctor is a Godot plugin that validates your scenes and nodes using a declarative, test-driven approach. Instead of writing procedural warning code, you define validation conditions using callables that focus on validation logic first, with error messages as metadata.
Realistically, when you add any @export variables, you don't want them to stay
unassigned. Nor do you want to @export a string only for it to stay empty. But
we often forget to assign a value to these. So, new in Godot Doctor v1.1 are
default validation conditions:
Godot Doctor will validate any nodes that have scripts attached to them (and any
opened resource), scan it's @export properties, and automatically reports on
unassigned objects and empty strings, without even needing to write a single
line of validation code!
ℹ️ You can turn off default validations alltogether in the settings asset, or you can add scripts to the ignore list, which will only disable default validations for those specific scripts.
Unlike
_get_configuration_warnings(),
Godot Doctor works without requiring the
@tool
annotation on your scripts. This means that you no longer have to worry about
your gameplay code being muddied by editor-specific logic.
See the difference for yourself:
Or how about this:
Our gameplay code stays much more clean and focused!
Godot has a problem with PackedScene type safety.
We can not strongly type PackedScenes.
This means that you may want to instantiate a scene that represents a Friend,
but accidentally assign an Enemy scene instead. Oops! Godot Doctor can
validate the type of a PackedScene, ensuring that the root of the scene that
you are instancing is of the expected type (e.g. has a script attached of that
type), before you even run the game.
## Example: A validation condition that checks whether the `PackedScene`
## variable `scene_of_foo_type` is of type `Foo`.
ValidationCondition.scene_is_of_type(scene_of_foo_type, Foo)Validations run automatically when you save scenes, providing immediate feedback during development. Errors are displayed in a dedicated dock, and you can click on them to navigate directly to the problematic nodes.
Godot Doctor can not only validate nodes in your scene, but Resource scripts
can define their own validation conditions as well. Very useful for validating
whether your resources have conflicting data (i.e. a value that is higher than
the maximum value), or missing references (i.e. an empty string, or a missing
texture).
Godot Doctor encourages you to write validation logic that resembles unit tests rather than write code that returns strings containing warnings. This encourages:
- Testable validation logic
- Organized code
- Better maintainability
- Human-readable validation conditions
- Separation of concerns between validation logic and error messages
Where _get_configuration_warnings() makes you write code that generates
strings, Godot Doctor lets you design your validation logic separately from the
error messages, making it easier to read and maintain.
The core of Godot Doctor is the ValidationCondition class, which takes a
callable and an error message:
# Basic validation condition
var condition = ValidationCondition.new(
func(): return health > 0,
"Health must be greater than 0"
)Optionally, you can also pass one of three severity levels (INFO, WARNING,
ERROR) as a third argument, which will adjust at what level of severity the
error is reported in the Godot Doctor dock:
# Validation condition with severity level
var condition = ValidationCondition.new(
func(): return health > 0,
"Health must be greater than 0",
ValidationCondition.Severity.ERROR
)For basic boolean validations, use the convenience simple() method, allowing
you to skip the func() wrapper:
# Equivalent to the above, but more concise
var condition = ValidationCondition.simple(
health > 0,
"Health must be greater than 0"
)There's also a bunch of often-used validation conditions available as static
methods on the ValidationCondition class, such as scene_is_of_type,
is_instance_valid, string_not_empty, and more, which saves you time writing
common validation logic.
You can find them all in
the ValidationCondition class
Using Callables allows you to reuse common validation methods:
func _is_more_than_zero(value: int) -> bool:
return value > 0
var condition = ValidationCondition.simple(
_is_more_than_zero(health),
"Health must be greater than 0"
)Or abstract away complex logic into separate methods:
var condition = ValidationCondition.new(
complex_validation_logic,
"Complex validation failed"
)
func complex_validation_logic() -> bool:
# Complex logic hereMaking use of variatic typing, Validation conditions can return arrays of other validation conditions, allowing you to nest validation logic where needed:
ValidationCondition.new(
func() -> Variant:
if not is_instance_valid(my_resource):
return false
return my_resource.get_validation_conditions(),
"my_resource must be assigned."
)- Automatic Discovery: When you save a scene, Godot Doctor scans all nodes
for
@exportproperties and a_get_validation_conditions()method - Instance Creation: For non-
@toolscripts, temporary instances are created to run validation logic - Condition Evaluation: Each validation condition's callable is executed
- Error Reporting: Failed conditions display their error messages in the Godot Doctor dock
- Navigation: Click on errors in the dock to navigate directly to the problematic nodes
For detailed examples and common validation patterns, see the examples README.
- Copy the
addons/godot_doctorfolder to your project'saddons/directory - Enable the plugin in Project Settings > Plugins
- The Godot Doctor dock will appear in the editor's left panel
use_default_validationsis on by default in the settings resource (addons/godot_doctor/settings/godot_doctor_settings.tres), so it will start reporting any of the default validations as soon as you save a scene.- Start adding custom validations by adding a
_get_validation_conditions()method to your scripts, then save your scenes to see validation results!
Godot Doctor is released under the MIT License. See the LICENSE file for details.
If you end up using Godot Doctor in your project, a line in your credits would be very much appreciated! 🐦
Godot Doctor is open-source and welcomes any contributions! Feel free to open issues or submit pull requests on GitHub.



