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

abtin
page 20: … protoc command… I had to additionally run the following go get commands in order to be able to compile protobuf code using go...
New
New
johnp
Running the examples in chapter 5 c under pytest 5.4.1 causes an AttributeError: ‘module’ object has no attribute ‘config’. In particula...
New
belgoros
Following the steps described in Chapter 6 of the book, I’m stuck with running the migration as described on page 84: bundle exec sequel...
New
swlaschin
The book has the same “Problem space/Solution space” diagram on page 18 as is on page 17. The correct Problem/Solution space diagrams ar...
New
jskubick
I’m under the impression that when the reader gets to page 136 (“View Data with the Database Inspector”), the code SHOULD be able to buil...
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
brunogirin
When I run the coverage example to report on missing lines, I get: pytest --cov=cards --report=term-missing ch7 ERROR: usage: pytest [op...
New
davetron5000
Hello faithful readers! If you have tried to follow along in the book, you are asked to start up the dev environment via dx/build and ar...
New
SlowburnAZ
Getting an error when installing the dependencies at the start of this chapter: could not compile dependency :exla, "mix compile" failed...
New

Other popular topics Top

AstonJ
I have seen the keycaps I want - they are due for a group-buy this week but won’t be delivered until October next year!!! :rofl: The Ser...
New
AstonJ
Do the test and post your score :nerd_face: :keyboard: If possible, please add info such as the keyboard you’re using, the layout (Qw...
New
Rainer
Not sure if following fits exactly this thread, or if we should have a hobby thread… For many years I’m designing and building model air...
New
PragmaticBookshelf
Learn different ways of writing concurrent code in Elixir and increase your application's performance, without sacrificing scalability or...
New
DevotionGeo
The V Programming Language Simple language for building maintainable programs V is already mentioned couple of times in the forum, but I...
New
Margaret
Hello everyone! This thread is to tell you about what authors from The Pragmatic Bookshelf are writing on Medium.
1139 25478 754
New
Maartz
Hi folks, I don’t know if I saw this here but, here’s a new programming language, called Roc Reminds me a bit of Elm and thus Haskell. ...
New
AstonJ
We’ve talked about his book briefly here but it is quickly becoming obsolete - so he’s decided to create a series of 7 podcasts, the firs...
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
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: