I am developing a REST API using CakePHP. The problem is regarding the validation of data that is sent as input parameters to my API. In the CakePHP documentation they have mentioned this. But how do I implement it for a REST API?
I want that if I add a validation something like this in app/Model/Table.php
:
public $validate = array(
'email' => 'email'
);
Then when I user makes the request myapi.com/resource?email=abc123
I want the API to respond like
status: 400
{
"message": "Invalid Parameter",
"url": "/resource"
}