Validating Our Quizzes
Let’s learn how to validate our quizzes.
We'll cover the following...
We'll cover the following...
We first need to validate a quiz. We are creating a module per validator, and only add models that take complex user data.
Declaring our module and some core functions
In /lib/mastery/boundary/quiz_validator.ex, we’ll write this code:
We have a core errors function that does the lion’s share of the work.
-
We have only two fields that have external input, an optional
:masteryfield and a required:titlefield. -
We pipe through those and return the responses. ...