marcotaubmann

marcotaubmann

Designing Elixir Systems with OTP: Fix Mastery.Boundary.Validator.check_field() (page 118)

When testing the code of page 118 in iex -S mix i think you should get:

iex(1)> Mastery.Boundary.QuizValidator.errors(%{mastery: 3})
[title: "is required"]

But instead you get:

iex(1)> Mastery.Boundary.QuizValidator.errors(%{mastery: 3})
:ok

This could be fixed by changing the first line of Page 118 (lib\mastery\boundary\validator.ex) from

  defp check_field(:ok, _errors, _field_name), do: :ok

to

  defp check_field(:ok, errors, _field_name), do: errors

Is this right?

First Post!

marcotaubmann

marcotaubmann

When using the fix from above, test driving the API (page 124) returns

iex(3)> Mastery.build_quiz Math.quiz_fields
[title: "must be a string"]

Which seem right, because either the Mastery.Examples.Math.quiz_fields() must be changed (it should return an string for title) or the Mastery.Boundary.QuizValidator.validate_title() must be changed (it should check for atoms not for strings).

Either way, to get :ok for iex(3)> Mastery.build_quiz Math.quiz_fields and iex(4)> Mastery.add_template Math.quiz.title, Math.template_fields instead of [] the validation calls in Mastery.build_quiz and Mastery.add_template (Build the API Layer Page 122) must check for []return values instead of :ok.

Still questioning myself if I’m on a wrong path here.

Where Next?

Popular Pragmatic Bookshelf topics Top

New
jeffmcompsci
Title: Design and Build Great Web APIs - typo “https://company-atk.herokuapp.com/2258ie4t68jv” (page 19, third bullet in URL list) Typo:...
New
GilWright
Working through the steps (checking that the Info,plist matches exactly), run the demo game and what appears is grey but does not fill th...
New
simonpeter
When I try the command to create a pair of migration files I get an error. user=> (create-migration "guestbook") Execution error (Ill...
New
edruder
I thought that there might be interest in using the book with Rails 6.1 and Ruby 2.7.2. I’ll note what I needed to do differently here. ...
New
patoncrispy
I’m new to Rust and am using this book to learn more as well as to feed my interest in game dev. I’ve just finished the flappy dragon exa...
New
jgchristopher
“The ProductLive.Index template calls a helper function, live_component/3, that in turn calls on the modal component. ” Excerpt From: Br...
New
brunogirin
When installing Cards as an editable package, I get the following error: ERROR: File “setup.py” not found. Directory cannot be installe...
New
a.zampa
@mfazio23 I’m following the indications of the book and arriver ad chapter 10, but the app cannot be compiled due to an error in the Bas...
New
roadbike
From page 13: On Python 3.7, you can install the libraries with pip by running these commands inside a Python venv using Visual Studio ...
New

Other popular topics Top

Exadra37
I am thinking in building or buy a desktop computer for programing, both professionally and on my free time, and my choice of OS is Linux...
New
AstonJ
There’s a whole world of custom keycaps out there that I didn’t know existed! Check out all of our Keycaps threads here: https://forum....
New
AstonJ
Just done a fresh install of macOS Big Sur and on installing Erlang I am getting: asdf install erlang 23.1.2 Configure failed. checking ...
New
Exadra37
I am asking for any distro that only has the bare-bones to be able to get a shell in the server and then just install the packages as we ...
New
rustkas
Intensively researching Erlang books and additional resources on it, I have found that the topic of using Regular Expressions is either c...
New
PragmaticBookshelf
Author Spotlight James Stanier @jstanier James Stanier, author of Effective Remote Work , discusses how to rethink the office as we e...
New
Help
I am trying to crate a game for the Nintendo switch, I wanted to use Java as I am comfortable with that programming language. Can you use...
New
First poster: bot
Large Language Models like ChatGPT say The Darnedest Things. The Errors They MakeWhy We Need to Document Them, and What We Have Decided ...
New
New
sir.laksmana_wenk
I’m able to do the “artistic” part of game-development; character designing/modeling, music, environment modeling, etc. However, I don’t...
New

Sub Categories: