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

:pre functions do not get nested values #52

Open
jwr opened this issue May 21, 2016 · 0 comments
Open

:pre functions do not get nested values #52

jwr opened this issue May 21, 2016 · 0 comments

Comments

@jwr
Copy link

jwr commented May 21, 2016

When nesting validation sets, functions supplied as :pre get the entire data structure passed to b/validate, not just the nested structure that they would normally get. This basically breaks their functionality.

Here's a more descriptive example:

(def billing-data
  {:country v/required
   :eu-vat-number [[v/required
                    :pre (comp countries/eu-country-codes :country)
                    :message "is required for EU countries"]]})

(def signup-data
  {:currency v/required
   :billing-data billing-data
   :account-data account-data
   ;; [...]
   })

In this example, :eu-vat-number validation will work if a billing-data map is being validated, but will not work as expected if signup-data is validated. The :pre function will get the entire signup-data map, which does not contain a :country key, therefore the :eu-vat-number validation will never run.

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

1 participant