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

Parser losing metadata? #1015

Open
Frozenlock opened this issue Mar 6, 2024 · 1 comment
Open

Parser losing metadata? #1015

Frozenlock opened this issue Mar 6, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@Frozenlock
Copy link

Looks like the parser is losing the metadata along the way.

(def id-schema
  [:and
   ;; Nested :and to be able to add metadata to generated content
   [:and {:gen/fmap #(with-meta % {:kw-id true})}
    [:cat {:gen/fmap vec}
     :keyword
     [:+ :string]]
    vector?]
   [:fn #(:kw-id (meta %))] ; <- causes issues with the parser?
   ])

(meta (mg/generate id-schema))
;=> {:kw-id true}

(m/parse id-schema (mg/generate id-schema))
;=> :malli.core/invalid

If you comment out the metadata test and try again, it works:

(def id-schema
  [:and
   ;; Nested :and to be able to add metadata to generated content
   [:and {:gen/fmap #(with-meta % {:kw-id true})}
    [:cat {:gen/fmap vec}
     :keyword
     [:+ :string]]
    vector?]
   ;[:fn #(:kw-id (meta %))] ; <- causes issues with the parser?
   ])

(m/parse id-schema (mg/generate id-schema))
;=> [:+_8X.u
 ["W3Iz5qe"
  "9r01WwNdDl91Gdzyk3QF7"
  "45BD4Z8qx6xa7ab5E5JbU6mLAv"
  "r01uuAvF6cmet7Kc964F7L"
  "BoUJv"
  "0q445EvwmMBj3JlaTYmT0n"]]
@ikitommi ikitommi added bug Something isn't working enhancement New feature or request and removed bug Something isn't working labels Mar 23, 2024
@ikitommi
Copy link
Member

There hasn't been promised about retaining meta-data, but there could and should be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants