Create Three Symfony Back Ends - Part #8 - Validate incoming JSON
Feb 14, 2023
What happens if the Symfony 4 JSON API consumer - i.e. our JavaScript developer - makes a typo, or submits the form data in some weird format? It would be kinda handy if we could stop any monkey business. This is a two part process. First, we need to ensure our Album entity enforces some validation constraints. This sounds rather computer science textbook, but in reality it means hey, don't be submitting null, or can you please make sure the dates are within these two acceptable time frames... and that kind of thing. It's actually pretty easy, and intuitive to use Symfony's Validation Constraints. Secondly, we will need a way to show these errors to our JSON API consumer. We will tackle that in the next video.