How to validate entity's proprty with enum type
There is an entity with property $language:
private Language $language = Language::ES;
On post request data with language from enum list (e.g. es) all is ok. But if value out of list response error (e.g. 00):
{
"title": "An error occurred",
"detail": "The data must belong to a backed enumeration of type App\\Core\\Language",
"status": 400,
"type": "/errors/400"
}
Choice and custom validator useless because they execute AFTER deserialization where that error appears. So i need proper 422 error response. What and how to fix?
You can use a less strictly typed input, and validate it before hydrating your real object in a custom processor. Would be great if Api platform could natively deal with it !
$language is a parameter of your object constructor, right ?
$language is a parameter of your object constructor, right ?
@bertrandseurot no. simple doctrine's entity.
Please help somebody
disable_type_enforcement ?
@soyuka what's it? i couldn't find documentation about it(
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.