Updated validate() to handle callbacks in an api call.