Closed (fixed)
Project:
Domain
Version:
3.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
20 Feb 2026 at 16:10 UTC
Updated:
9 Mar 2026 at 13:50 UTC
Jump to comment: Most recent
Domain records entities are validated on a form using a service. Drupal is moving towards config validation, see #3427641: [meta] Config validation for a more reliable Drupal + reliable Recipes from the start
Move DomainValidator logic to Constraints
None
To be determined
None
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
mably commentedCommit 1: Move DomainValidator logic to Constraints
Adds two entity-level constraint plugins to the domain entity:
hook_domain_validate_alterso existing alter implementations keep working.Both constraints are declared on the
Domainentity annotation and covered by a new kernel test (DomainHostnameConstraintTest).This commit is purely additive — no existing code is modified.
Commit 2: Wire form and Drush to use entity constraint validation
Replaces the direct
DomainValidator::validate()calls inDomainFormandDomainCommandswith entity constraint validation via$entity->getTypedData()->validate(), removing the duplicated hostname checking logic.DomainHostname/DomainUniqueHostnameviolations to form errors. TheRendererInterfacedependency is removed (was only used to render the error item list). ThecheckResponse()andgetRequiredFields()calls are unchanged.validateDomain()which returns aConstraintViolationListInterfaceinstead of astring[]. The manual hostname uniqueness loop is removed (handled by the constraint); only the id uniqueness check remains.@trigger_errornotice. The method body is kept intact for backward compatibility.BC breaking changes
RendererInterfacewas removed and parameter order shifted. Any code extendingDomainFormwith aparent::__construct()call will need updating.string[]toConstraintViolationListInterface. The method isprotected, so only subclasses overriding or calling it are affected.All 54 domain tests pass (1912 assertions).
Comment #5
idebr commentedThe constraints for properties are typically added on the property level, see for reference #3379091: Make NodeType config entities fully validatable and #3447286: Add validation constraints to image.style.*
Ideally all properties have validation, which would enable the config entity to be FullyValidatable. The https://drupal.org/project/config_inspector provides Drush integration to check the constraints are properly applied.
For scheme and domain_id, this can be done in a follow-up as these properties currently have no validation.
Comment #6
mably commentedHi @idebr, not sure to fully understand, could try to explain a bit more in details or eventually provide an MR?
EDIT: Ok, I think I got it, you suggest to apply the constraints at the property level, not the entity level.
Will work on it.
Comment #7
mably commentedComment #8
mably commentedComment #9
mably commented@idebr looks like domain records are now fully validatable in Config Inspector.
Comment #10
mably commentedLet's also fix the domain alias records validation.
Comment #11
idebr commentedThe DomainUniqueHostname can extend the Drupal\Core\Validation\Plugin\Validation\Constraint\UniqueFieldConstraint to remove some boilerplate, see for reference https://git.drupalcode.org/project/drupal/-/blob/main/core/modules/file/...
Comment #12
mably commentedDoesn't seem possible.
Here is what Claude says:
Comment #13
idebr commentedOh I see, good to go then!
Comment #15
mably commented