codeforkansascity / clear_my_record_backend

Backend API Code for Clear My Record, an application to assist people the process of expunging their criminal convictions.
MIT License
5 stars 3 forks source link

Form API return values #81

Open zmon opened 5 years ago

zmon commented 5 years ago

When a form fails validation on the server, the API should return errors that will be displayed on the UI.

Screen Shot 2019-06-19 at 12 02 54 AM

An example of the return

URL . POST /client Status code: 422 Unprocessable Entity Payload:

active: 0
name: ""
_token: "zEwcjrMwbfbK33duxu7GlhL27oUArCpONL0GqLSZ"

Response:

{  
   "message":"The given data was invalid.",
   "errors":{  
      "name":[  
         "The name field is required."
      ]
   }
}

NOTE: the name is an array allowing for more than one error message to be returned.