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

sdmoralesma
Title: Web Development with Clojure, Third Edition - migrations/create not working: p159 When I execute the command: user=> (create-...
New
jdufour
Hello! On page xix of the preface, it says there is a community forum "… for help if your’re stuck on one of the exercises in this book… ...
New
HarryDeveloper
Hi @venkats, It has been mentioned in the description of ‘Supervisory Job’ title that 2 things as mentioned below result in the same eff...
New
Chrichton
Dear Sophie. I tried to do the “Authorization” exercise and have two questions: When trying to plug in an email-service, I found the ...
New
brian-m-ops
#book-python-testing-with-pytest-second-edition Hi. Thanks for writing the book. I am just learning so this might just of been an issue ...
New
curtosis
Running mix deps.get in the sensor_hub directory fails with the following error: ** (Mix) No SSH public keys found in ~/.ssh. An ssh aut...
New
jskubick
I found an issue in Chapter 7 regarding android:backgroundTint vs app:backgroundTint. How to replicate: load chapter-7 from zipfile i...
New
andreheijstek
After running /bin/setup, the first error was: The foreman' command exists in these Ruby versions: That was easy to fix: gem install fore...
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
redconfetti
Docker-Machine became part of the Docker Toolbox, which was deprecated in 2020, long after Docker Desktop supported Docker Engine nativel...
New

Other popular topics Top

PragmaticBookshelf
Design and develop sophisticated 2D games that are as much fun to make as they are to play. From particle effects and pathfinding to soci...
New
DevotionGeo
I know that -t flag is used along with -i flag for getting an interactive shell. But I cannot digest what the man page for docker run com...
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
PragmaticBookshelf
Tailwind CSS is an exciting new CSS framework that allows you to design your site by composing simple utility classes to create complex e...
New
AstonJ
If you are experiencing Rails console using 100% CPU on your dev machine, then updating your development and test gems might fix the issu...
New
PragmaticBookshelf
Learn different ways of writing concurrent code in Elixir and increase your application's performance, without sacrificing scalability or...
New
AstonJ
Biggest jackpot ever apparently! :upside_down_face: I don’t (usually) gamble/play the lottery, but working on a program to predict the...
New
PragmaticBookshelf
Author Spotlight James Stanier @jstanier James Stanier, author of Effective Remote Work , discusses how to rethink the office as we e...
New
PragmaticBookshelf
Programming Ruby is the most complete book on Ruby, covering both the language itself and the standard library as well as commonly used t...
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: