Add validationRules() method to base Dto class#79
Merged
dereuromark merged 2 commits intomasterfrom Feb 8, 2026
Merged
Conversation
Returns framework-agnostic validation rules extracted from field metadata.
Enables framework plugins to bridge DTO rules to native validators.
Example: $dto->validationRules() returns:
[
'name' => ['required' => true, 'minLength' => 2, 'maxLength' => 50],
'email' => ['pattern' => '/^[^@]+@[^@]+$/'],
]
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #79 +/- ##
============================================
+ Coverage 82.93% 82.99% +0.05%
- Complexity 1375 1381 +6
============================================
Files 40 40
Lines 3323 3334 +11
============================================
+ Hits 2756 2767 +11
Misses 567 567 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
dereuromark
added a commit
to php-collective/symfony-dto
that referenced
this pull request
Feb 8, 2026
- Add DtoConstraintBuilder::fromDto() to convert DTO validation rules to Symfony Validator constraints - Maps required/minLength/maxLength/min/max/pattern to NotBlank/Length/Range/Regex - Add symfony/validator to require-dev and suggest - Add comprehensive tests (8 tests, 21 assertions) - Update docs with Validation Bridge section - Depends on php-collective/dto#79 (validationRules method)
dereuromark
added a commit
to php-collective/symfony-dto
that referenced
this pull request
Feb 9, 2026
* Add Symfony validation bridge (DtoConstraintBuilder) - Add DtoConstraintBuilder::fromDto() to convert DTO validation rules to Symfony Validator constraints - Maps required/minLength/maxLength/min/max/pattern to NotBlank/Length/Range/Regex - Add symfony/validator to require-dev and suggest - Add comprehensive tests (8 tests, 21 assertions) - Update docs with Validation Bridge section - Depends on php-collective/dto#79 (validationRules method) * Add Symfony validator constraint bridge for DTO validation rules * Fix CI: widen validator to ^7.0|^8.0 for PHP 8.2, add PHPStan ignore * Rename docs/Usage.md to docs/README.md * Update php-collective/dto constraint * Update symfony/validator version constraint
dereuromark
added a commit
to php-collective/symfony-dto
that referenced
this pull request
Feb 9, 2026
* Add Symfony validation bridge (DtoConstraintBuilder) - Add DtoConstraintBuilder::fromDto() to convert DTO validation rules to Symfony Validator constraints - Maps required/minLength/maxLength/min/max/pattern to NotBlank/Length/Range/Regex - Add symfony/validator to require-dev and suggest - Add comprehensive tests (8 tests, 21 assertions) - Update docs with Validation Bridge section - Depends on php-collective/dto#79 (validationRules method) * Add Symfony validator constraint bridge for DTO validation rules * Fix CI: widen validator to ^7.0|^8.0 for PHP 8.2, add PHPStan ignore * Add DTO mapper and JSON response helpers * Update php-collective/dto constraint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
validationRules()method that returns framework-agnostic validation rules extracted from field metadata. This enables framework plugins (CakePHP, Laravel, Symfony) to bridge DTO validation rules to their native validator systems.Usage
Includes tests for both populated and empty metadata.