My rule is "'customer_id' => "required|string|min:10"", when I use wrong value for it, the pointer is correct,
{
"status": "422",
"title": "Unprocessable Entity",
"detail": "The customer id must be at least 10 characters.",
"source": {
"pointer": "/data/attributes/customer_id"
}
}
but if the value of customer_id was not set in the request body, the pointer only shows "/data",
{
"status": "422",
"title": "Unprocessable Entity",
"detail": "The customer id field is required.",
"source": {
"pointer": "/data"
}
}
Is this wrong or it should be like this?
Is this correct.
If the field foo is required, and is not present in the JSON sent by the client, it would be invalid to give them a JSON pointer of /data/attributes/foo because that is pointing to a field that does not exist in their JSON.
Instead /data is accurate, because the resource object that is at /data is invalid as it is missing a required field. So /data points to the field that is invalid in their request.
Note that this only applies if the field is not present in their request data. For example, if they sent a null value for foo, the field foo would exist in their request so a pointer to /data/attributes/foo is accurate.
Most helpful comment
Is this correct.
If the field
foois required, and is not present in the JSON sent by the client, it would be invalid to give them a JSON pointer of/data/attributes/foobecause that is pointing to a field that does not exist in their JSON.Instead
/datais accurate, because the resource object that is at/datais invalid as it is missing a required field. So/datapoints to the field that is invalid in their request.Note that this only applies if the field is not present in their request data. For example, if they sent a
nullvalue forfoo, the fieldfoowould exist in their request so a pointer to/data/attributes/foois accurate.