In my entity class I have defined all the expected argument types for the setters and return types of the getters. Later, when I have a form which uses the said class, I get an error if some of the fields in the form is empty because the form component tries to pass null to the setter instead of string.
I get the following exception when I submit the form:
Expected argument of type "string", "NULL" given
500 Internal Server Error - InvalidArgumentException
The exception is thrown from vendor/symfony/symfony/src/Symfony/Component/PropertyAccess/PropertyAccessor.php at line 254
Is there a way to convert the "null" value to empty string before passing it to the object, and let the validator argue about it?