Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Quickstart example #1066

Closed
wants to merge 1 commit into from
Closed

Fix Quickstart example #1066

wants to merge 1 commit into from

Conversation

DjebbZ
Copy link

@DjebbZ DjebbZ commented Jul 9, 2024

Hello,

Problem:

In the Quickstart of the README, you reference other schema with the #'<SCHEMA> syntax. But it doesn't work, it gives :malli.core/invalid-schema error.

Steps to reproduce:

  1. Start a new REPL with malli in the deps.edn file
  2. Paste the code of the Quickstart
  3. When generating with malli.generator or validating a handcrafted User object, it always gives the following error : ; :malli.core/invalid-schema {:schema #'user/UserId}

How to fix:

Just remove the #' from schema references. Note that I still get another error :malli.core/invalid-ref {:ref [:map [:id :string] [:address [:map [:street :string] [:country [:enum "FI" "UA"]]]] [:friends [:set #:gen{:max 2} [:ref #'user/User]]]]}. It maybe because I don't know how to use :ref. But in my real world app removing #' totally fixed the problem.

Further suggestion (if I may) :

The Quickstart is the only place I found where you compose a schema out of smaller schema and demonstrate composition through schema reuse. Is it because it's limited? I think it deserves at least a formal documentation like : "You can create a schema with any Schema syntax and just reuse it to compose bigger schema and avoid code duplication` or something like that. You get the point I hope.

Thanks!

Hello,

Problem:

In the Quickstart of the README, you reference other schema with the `#'<SCHEMA>` syntax. But it doesn't work, it gives `:malli.core/invalid-schema` error.

Steps to reproduce:

1. Start a new REPL with malli in the `deps.edn` file
2. Paste the code of the Quickstart
3. When generating with `malli.generator` or validating a handcrafted User object, it always gives the following error : `; :malli.core/invalid-schema {:schema #'user/UserId}`

How to fix:

Just remove the `#'` from schema references. Note that I still get another error `:malli.core/invalid-ref {:ref [:map [:id :string] [:address [:map [:street :string] [:country [:enum "FI" "UA"]]]] [:friends [:set #:gen{:max 2} [:ref #'user/User]]]]}`. It maybe because I don't know how to use `:ref`. But in my real world app removing `#'` totally fixed the problem.

Further suggestion (if I may) :

The Quickstart is the only place I found where you compose a schema out of smaller schema and demonstrate composition through schema reuse. Is it because it's limited? I think it deserves at least a formal documentation like : "You can create a schema with any Schema syntax and just reuse it to compose bigger schema and avoid code duplication` or something like that. You get the point I hope.

Thanks!
@ikitommi
Copy link
Member

ikitommi commented Jul 9, 2024

Thanks. Var-registry was introduced in 0.14.0 and the example code works with it. Did you try with an older version?

I agree that the documentation could be improved.

@DjebbZ
Copy link
Author

DjebbZ commented Jul 9, 2024

You just made me realize that we have different versions of malli in our monorepo, some deps.edn declare v0.14.0 while others v0.9.2... Is there a way to view (or infer) the version at runtime?

@ikitommi
Copy link
Member

ikitommi commented Jul 9, 2024

nothing in malli for that, you can use clojurea/deps tooling to get the resolved classpath.

@ikitommi ikitommi closed this Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants