Validation Guide#
Entity Builder uses a comprehensive two-stage validation system to catch errors before execution.
Two-Stage Validation#
Stage 1: Operation Validation#
Each operation validates its own specific requirements:
| Operation | Validates |
|---|---|
create_bundle |
Entity type exists, supports bundles |
create_field |
Field type exists, bundle valid |
configure_form_mode |
Widget exists, compatible with field type |
configure_view_mode |
Formatter exists, compatible with field type |
create_field_group |
Format type valid, parent exists |
Stage 2: Validator Plugins#
Cross-cutting validators check rules across all operations:
| Validator | Checks |
|---|---|
DependencyValidator |
Referenced entities exist |
RequiredFieldsValidator |
Required properties present |
UniqueNameValidator |
No naming conflicts |
FieldTypeValidator |
Field type plugin exists |
WidgetCompatibilityValidator |
Widget supports field type |
FormatterCompatibilityValidator |
Formatter supports field type |
CircularDependencyValidator |
No circular dependencies |
Common Validation Errors#
Field Type Errors#
Error: Field type "invalid_type" does not exist.
Cause: Misspelled field type or missing module.
Solution:
Valid field types:
- string, string_long
- text, text_long, text_with_summary
- integer, decimal, float
- boolean
- datetime, daterange
- entity_reference
- image, file
- link, email, telephone
- list_string, list_integer, list_float
Widget/Formatter Errors#
Error: Widget "invalid_widget" not found.
Cause: Misspelled widget or incompatible with field type.
Solution:
Error: Widget "string_textfield" is not compatible with field type "text_long".
Cause: Wrong widget for the field type.
Solution: Use a compatible widget:
| Field Type | Compatible Widgets |
|---|---|
string |
string_textfield |
text_long |
text_textarea |
text_with_summary |
text_textarea_with_summary |
integer, decimal |
number |
boolean |
boolean_checkbox, options_buttons |
entity_reference |
entity_reference_autocomplete, options_select, options_buttons |
Bundle Errors#
Error: Bundle "missing_bundle" not found for entity type "node".
Cause: Referencing a bundle that doesn't exist.
Solutions:
-
Create the bundle in the same definition:
-
Or ensure the bundle exists in Drupal first.
Entity Reference Errors#
Error: Target bundle "category" does not exist for entity type "taxonomy_term".
Cause: Entity reference targets a non-existent bundle.
Solution: Create the target bundle first:
Circular Dependency Errors#
Error: Circular dependency detected: A > B > C > A
Cause: Operations depend on each other in a cycle.
Example of circular dependency:
Solution: Remove one direction of the reference or use a different approach.
Naming Errors#
Error: Field name must start with "field_".
Solution:
Error: Group name must start with "group_".
Solution:
Batch Context Awareness#
Validators understand what will be created in the same batch:
The field can reference the bundle even though it doesn't exist yet - because it will be created in the same batch.
Validation Commands#
Validate a File#
Output (success):
Output (errors):
Validate in UI#
- Click Validate in the toolbar
- Errors show as red highlights
- Hover over cells for error details
Validation Severity#
| Level | Meaning | Blocks Apply? |
|---|---|---|
| Error | Must fix | Yes |
| Warning | Should review | No |
| Info | FYI | No |
Best Practices#
- Validate frequently during editing
- Fix errors immediately - don't let them accumulate
- Preview before apply to see the full operation list
- Check dependencies are in the correct order
- Use discovery to find correct plugin IDs