refactoring on request validation and new error json for bad requests