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

Custom validation functions: Allow programmatically defining :error/path #975

Open
mkreis opened this issue Nov 30, 2023 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@mkreis
Copy link

mkreis commented Nov 30, 2023

Open this feature request as discussed here: https://clojurians.slack.com/archives/CLDK6MFMK/p1701249325700779

It would be great if it was possible to programmatically define :error/path depending on the validation function (and the data to be validated).

In below example from the docs :error/path only accept vectors is hard-coded to [:password2]:

(-> [:and [:map
           [:password string?]
           [:password2 string?]]
     [:fn {:error/message "passwords don't match"
           :error/path [:password2]}
       (fn [{:keys [password password2]}]
         (= password password2))]]
    (m/explain {:password "secret"
                :password2 "faarao"})
    (me/humanize))
; {:password2 ["passwords don't match"]}
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