
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
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.
Popular Pragmatic Bookshelf topics










Other popular topics










Categories:
Sub Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /rails
- /js
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /ash
- /opensuse
- /vscode
- /centos
- /php
- /deepseek
- /html
- /scala
- /zig
- /debian
- /nixos
- /lisp
- /agda
- /react-native
- /textmate
- /sublime-text
- /kubuntu
- /arch-linux
- /ubuntu
- /revery
- /django
- /manjaro
- /spring
- /diversity
- /lua
- /nodejs
- /julia
- /c
- /slackware
- /neovim