Skip to content

Lesson 12 (Model Validation and Enums)

Courtney Frey edited this page Apr 14, 2022 · 3 revisions

Lesson 12: Model Validation and Enums

In the prep work for this lesson, the students learned

  1. How and why to validate model data in Spring Boot.
  2. How to use Java Validation API annotations.
  3. How to employ good error handling when bad data is entered.
  4. What enum data types are how to write them in Java.

Announcements

  1. Check with your course manager for any important announcements.
  2. Lesson 13 is a designated work day.

For Part-Time Students:

  1. Students should have assignment 3 completed by today's class.

For Full-Time Students:

  • Welcome to Days 19-21!
  • Assignment 3 due at end of Day 22
  • Day 19:
    • Lesson 12
  • Day 20:
    • Assignment 3 Work Day
  • ** Day 21**:
    • Assignment 3 Work Day
    • Have students work on setting up MySQL. Directions in the SQL textbook.

Large Group Time (Instructor)

Lesson 12 Topics That Require Careful Attention

  1. You may want to introduce the topic of model validation with a more widely-scoped discussion of data handling:

    a. Why is good data important?

    b. How can bad data be dangerous?

  2. Be sure that the students can differentiate between client and server side validation tools.

  3. Discuss some commonly annotations from the Java Validation API.

  4. Walk the students through the validation flow mentioned in the text, perhaps with a new sample field on the Event model from coding-events .

  5. Compare strong error message and handling techniques to weaker examples.

  6. Address enum data types:

    a. How to create an enum class and add custom properties.

    b. How to add an enum type field onto a class.

    c. What kind of data is handled well with enums.

Small Group Time: Lesson 12 Studio (TA Notes)

  1. Today's studio asks students to add validation for the User model in their spa day application. If they were not able to complete the user signup studio work from the previous class, they will still be able to work on this studio.
  2. Starter code is provided for the students in the LaunchCodeEducation/spa-day-starter-code repository. If they have not already added this as an upstream remote repository in addition to their own forked version, they may need to in order to fetch the appropriate starter branch for the studio.
  3. Students are mostly on their own to decide what their form validation should look like, although most of the work resembles the tasks we demonstrate in the in-book codeing-events examples.
  4. For those students who try the Bonus Mission, try talking with them about the relative merits of each password checking method.