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

Should we abstract validation engines? #57

Open
niquola opened this issue Apr 19, 2023 · 1 comment
Open

Should we abstract validation engines? #57

niquola opened this issue Apr 19, 2023 · 1 comment

Comments

@niquola
Copy link
Member

niquola commented Apr 19, 2023

Can we generalize validation and abstract away zen/schema from the zen core?

@KGOH
Copy link
Contributor

KGOH commented Apr 24, 2023

@niquola could you elaborate on that? From what I see, you can replace validation engine by doing

(zen.schema/register-schema-pre-process-hook!
  :my-validate my-props-validate)
  
(zen.schema/register-schema-post-process-hook!
  :my-validate my-unknown-keys-post-process-hook)

(zen.schema/register-compile-key-interpreter!
  [:type :my-validate] my-compile-type-validation)
  
(zen.schema/register-compile-key-interpreter!
  [:keys :my-validate] my-compile-keys-validation)
;; etc

And you can run that by doing

(zen.schema/apply-schema ztx vtx schema data {:interpreters [:my-validate]})

This approach allows to use schema for any purposes and is not limited to validation, as the zen.schema namespace doesn't explicitly rely/mention validation in any way

Related issue:
#38

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

No branches or pull requests

2 participants