Closed
Description
Description
This exception does not provide property path for the extra attributes found. So if they are in nested object, We are not able to construct reliable validation errors for our users, rather than a generic "Invalid input data: extra attributes found".
Example
class CategoryDto {
public string $name;
}
class ProductDto {
public string $name;
public Category $category1;
public Category $category2;
}
{
"name": "Product name",
"category1": {
"name": "Category name",
"extra": "some extra field"
},
"category2": {
"name": "Category name"
}
}
If I deserialize this JSON into ProductDto
, it results in a ExtraAttributesException
, which is correct.
But, the ExtraAttributesException::getExtraAttributes()
returns the following:
array(1) {
[0]=>
string(5) "extra"
}
Which doesn't provide info about the exact property (path included) that is not allowed.