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

Inconsistent results from s/valid? and s/explain when trying to spec list of values #275

Open
OknoLombarda opened this issue May 24, 2023 · 0 comments

Comments

@OknoLombarda
Copy link

When using spec-tools ("0.10.5") to spec a list of values, result spec produces inconsistent results when validated against in s/valid? and s/explain.

Clojure CLI version 1.11.1.1273

Minimal example:

(ns case
  (:require [spec-tools.data-spec :as ds]
            [clojure.spec.alpha :as s]))

(def invalid-data {:cards (list 66)})

(def valid-data {:cards [66]})

(def cards
  {:cards [int?]})

(defn do-stuff [data]
  (if (s/valid? (ds/spec ::sp cards) data)
    (println "Conforms to spec according to 'valid?'")
    (println "Does not conform to spec according to 'valid?'"))
  (if (s/explain-data (ds/spec ::sp cards) data)
    (println "Does not conform to spec according to 'explain-data'")
    (println "Conforms to spec according to 'explain-data'")))

(comment
  (do-stuff invalid-data)
  (do-stuff valid-data))

For some reason s/valid? and s/explain produce different result when a list is used, but same when a vector is used. When I tried to reproduce this issue with spec created directly with clojure.spec.alpha, everything was fine, so it seems the problem is with spec-tools

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