Added validate function. Checks the response format.