Validating

Let’s learn to apply validation to the form fields.

While playing with the results of the application build so far, our hypothetical client notices something. If they enter an invalid price or forget to set up a product description, the application happily accepts the form and adds a line to the database. A missing description is embarrassing and a price of $0.00 costs them actual money, so they asked that we add validation to the application. No product should be allowed in the database if it has an empty title or description field, an invalid URL for the image, or an invalid price.

Get hands-on with 1400+ tech skills courses.