Problem description:
When using a custom error message with the argument {data:value} in the error message template, if the data value is null, the error message will contains the string "{data:value}" instead of just nothing.
How to reproduce:
Here is a schema configuration with:
'$error' => [
'type' => 'The data should be a valid resource identifier ({expected}), "{data:value}" ({data:type}) given.',
]
Let's say a null value is given to the schema, the rendered error message will return:
The data should be a valid resource identifier (integer), "{data:value}" (null) given.
The expected return should be:
The data should be a valid resource identifier (integer), "" (null) given.
Issue:
The issue is in the ErrorFormatter where the key to replaced is searched with an isset function. But isset determine if a variable is declared and is different than null, which is the problem. The array_key_exists function should be better in order to get null values and to replace the key in the error template message.
Version used: 2.3.0
Problem description: When using a custom error message with the argument
{data:value}
in the error message template, if the data value isnull
, the error message will contains the string "{data:value}" instead of just nothing.How to reproduce: Here is a schema configuration with:
Let's say a
null
value is given to the schema, the rendered error message will return:The data should be a valid resource identifier (integer), "{data:value}" (null) given.
The expected return should be:
The data should be a valid resource identifier (integer), "" (null) given.
Issue: The issue is in the ErrorFormatter where the key to replaced is searched with an
isset
function. Butisset
determine if a variable is declared and is different than null, which is the problem. Thearray_key_exists
function should be better in order to get null values and to replace the key in the error template message.