Checking Input by Hand

A server checks every request body before it saves anything, because any program can send anything, and a validation function collects every problem (a missing field, the wrong type, text that's too long, a value that isn't allowed) so the API can answer 400 with the whole list.

By

Updated

Cheat sheet for Checking Input by Hand: A server checks every request body before it saves anything, because any program can send anything, and a validation function collects every problem (a missing field, the wrong type, text that's too long, a value that isn't allowed) so the API can answer 400 w
Category
Node.js
Level
Apprentice
Tags
400 Bad Request, Client-Side Validation, nodejs, Request Body (rest-api), rest-api, Server-Side Validation