I have a request like http://example.com?value=xyz
and i have to write GET for this.
The requirement is, when i have a value, the response has to be for hat particular record "xyz" from database. But if the request ishttp://example.com
i.e without value, it has to retrieve all values from the DB.
So for achieveing this, I have (@RequestParam(value= "name", required=false)String name) in my request. i.e marked the value as optional
But the problem is when my request is http://example.com?value=
i.e without a value, i must throw 'request is invalid' as error and not retrieve all the values from the DB. But in my case when i mark the param as optional, it retrieves all records from DB.
Is there a way to do validations for optional request parameters?