Add field name into SchemaValidator error messages. #7164

Open
opened 2026-01-22 15:45:53 +01:00 by admin · 1 comment
Owner

Originally created by @Justinas-Jurciukonis on GitHub (Jun 8, 2023).

Feature Request

When running Symfony Doctrine validation there is missing field name that has failed.
It would be great to know field name

Q A
New Feature yes
RFC no
BC Break no

Summary

Current output is as follows:

 [FAIL] The entity-class App\Entity\Order mapping is invalid:
 * The referenced column name 'order_id' has to be a primary key column on the target entity class 'App\Entity\Order'.
 * The referenced column name 'coupon_id' has to be a primary key column on the target entity class 'App\Entity\Coupon'.
 * The referenced column name 'order_id' has to be a primary key column on the target entity class 'App\Entity\Order'.
 * The referenced column name 'discount_value_id' has to be a primary key column on the target entity class 'App\Entity\DiscountValue'.
 * The referenced column name 'order_id' has to be a primary key column on the target entity class 'App\Entity\ShippingInformation'.

As you can see there is repeated columns and entities that has invalid mapping (e.g. columns were moved from mappedBy to inversedBy). It's very unclear what and where to check.


Simply adding [{$assoc['fieldName']}] would help with that:

 [FAIL] The entity-class App\Entity\Order mapping is invalid:
 * [coupons] The referenced column name 'order_id' has to be a primary key column on the target entity class 'App\Entity\Order'.
 * [coupons] The referenced column name 'coupon_id' has to be a primary key column on the target entity class 'App\Entity\Coupon'.
 * [discounts] The referenced column name 'order_id' has to be a primary key column on the target entity class 'App\Entity\Order'.
 * [discounts] The referenced column name 'discount_value_id' has to be a primary key column on the target entity class 'App\Entity\DiscountValue'.
Originally created by @Justinas-Jurciukonis on GitHub (Jun 8, 2023). ### Feature Request When running Symfony Doctrine validation there is missing field name that has failed. It would be great to know field name | Q | A |------------ | ------ | New Feature | yes | RFC | no | BC Break | no #### Summary Current output is as follows: ``` [FAIL] The entity-class App\Entity\Order mapping is invalid: * The referenced column name 'order_id' has to be a primary key column on the target entity class 'App\Entity\Order'. * The referenced column name 'coupon_id' has to be a primary key column on the target entity class 'App\Entity\Coupon'. * The referenced column name 'order_id' has to be a primary key column on the target entity class 'App\Entity\Order'. * The referenced column name 'discount_value_id' has to be a primary key column on the target entity class 'App\Entity\DiscountValue'. * The referenced column name 'order_id' has to be a primary key column on the target entity class 'App\Entity\ShippingInformation'. ``` As you can see there is repeated columns and entities that has invalid mapping (e.g. columns were moved from `mappedBy` to `inversedBy`). It's very unclear what and where to check. ---- Simply adding `[{$assoc['fieldName']}]` would help with that: ``` [FAIL] The entity-class App\Entity\Order mapping is invalid: * [coupons] The referenced column name 'order_id' has to be a primary key column on the target entity class 'App\Entity\Order'. * [coupons] The referenced column name 'coupon_id' has to be a primary key column on the target entity class 'App\Entity\Coupon'. * [discounts] The referenced column name 'order_id' has to be a primary key column on the target entity class 'App\Entity\Order'. * [discounts] The referenced column name 'discount_value_id' has to be a primary key column on the target entity class 'App\Entity\DiscountValue'. ```
Author
Owner

@greg0ire commented on GitHub (Jun 8, 2023):

Looks cool! Would you care to send a pull request (against 2.16.x?)

@greg0ire commented on GitHub (Jun 8, 2023): Looks cool! Would you care to send a pull request (against 2.16.x?)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7164