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

Non-flowing :and parser #1167

Closed
wants to merge 4 commits into from

Conversation

frenchy64
Copy link
Collaborator

@frenchy64 frenchy64 commented Jan 28, 2025

Close #1166

Could also provide a separate schema (called and- in spec2).

Approach from spec2

Original slack thread

TODO

  • unparsing (why is this invalid?)
               (let [s [:and {:parse :non-flowing}
                        [:catn ["a" :int] ["b" :keyword]]
                        [:fn vector?]]]
                 (m/unparse s (m/parse s [3 :x])))

@opqdonut
Copy link
Member

I'm not sure I see who would ever want the current behaviour of :and + parse? It seems to me it would be pretty difficult to use the current :and so that it works both when validating and parsing. I guess most users only validate, and making :and non-flowing wouldn't affect them?

@frenchy64
Copy link
Collaborator Author

Yes, the only case I can think of is [:and [:fn vector?] [:catn ...]] where the simpler parsing goes first and flows to the more complex one.

@frenchy64
Copy link
Collaborator Author

After some thought, I agree it makes a lot of sense to only parse the first conjunct. This also aligns with the :and generator, where the first conjunct provides the generator and the rest filter via their validators. I'll sketch it out in another PR.

@frenchy64
Copy link
Collaborator Author

Superseded by #1182

@frenchy64 frenchy64 closed this Mar 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants