# \#clojure\_spec

**URL:** https://clojureverse.org/tag/clojure-spec/10.md

[Latest](https://clojureverse.org/latest.md) · [Categories](https://clojureverse.org/categories.md) · [Tags](https://clojureverse.org/tags.md)

---

## [Spec instrumentation only checks fdef :args?](https://clojureverse.org/t/spec-instrumentation-only-checks-fdef-args/11018)

<div class="topic-metadata">

**Author:** [@darrenaustin](https://clojureverse.org/u/darrenaustin)\
**Replies:** 4\
**Last updated:** [November 26, 2024, 5:41am UTC](https://clojureverse.org/t/spec-instrumentation-only-checks-fdef-args/11018 "2024-11-26T05:41:15Z")

</div>

Hey folks, Sorry if this has been answered elsewhere (in which case, please point me in the right direction), but why doesn’t clojure.spec.test.alpha/instrument test anything other than the :args of an fdef? I was hopi…

---

## [Couldn't satisfy such-that predicate after 100 tries {} when trying to generate samples from spec definition](https://clojureverse.org/t/couldnt-satisfy-such-that-predicate-after-100-tries-when-trying-to-generate-samples-from-spec-definition/11064)

<div class="topic-metadata">

**Author:** [@metatron](https://clojureverse.org/u/metatron)\
**Replies:** 2\
**Last updated:** [December 16, 2024, 4:52am UTC](https://clojureverse.org/t/couldnt-satisfy-such-that-predicate-after-100-tries-when-trying-to-generate-samples-from-spec-definition/11064 "2024-12-16T04:52:39Z")

</div>

Given the following spec definitions (ns spec-playground.spec.standard (:require \[clojure.spec.alpha :as s\])) (defn- state-length \[str\] (= 2 (count str))) (s/def ::field-one string?) (s/def ::field-two string?) (s/…

---

## [Nuisances with map destructuring](https://clojureverse.org/t/nuisances-with-map-destructuring/10017)

<div class="topic-metadata">

**Author:** [@Webdev\_Tory](https://clojureverse.org/u/Webdev_Tory)\
**Replies:** 2\
**Last updated:** [May 22, 2023, 3:40pm UTC](https://clojureverse.org/t/nuisances-with-map-destructuring/10017 "2023-05-22T15:40:07Z")

</div>

Just venting about a couple of nuisances that came up while refactoring a function to take all args in a map. Can’t provide :keys an array thanks to spec errors. I used to sometimes destructure with (let \[ks \[:someof …

---

## [Spec riddle - parsing \[::key1 val ::key2 val \[::key3 val\] ...\]](https://clojureverse.org/t/spec-riddle-parsing-key1-val-key2-val-key3-val/9642)

<div class="topic-metadata">

**Author:** [@ryantate](https://clojureverse.org/u/ryantate)\
**Replies:** 6\
**Last updated:** [December 23, 2022, 7:08pm UTC](https://clojureverse.org/t/spec-riddle-parsing-key1-val-key2-val-key3-val/9642 "2022-12-23T19:08:22Z")

</div>

Let’s say you have specs like so: (s/def ::string string?) (s/def ::number number?) (s/def ::map map?) ... \[many more\] ... And let’s say you want to spec a data format of vectors of uncontained key-value pairs and othe…

---

## [Spec and post condition on lazySeq](https://clojureverse.org/t/spec-and-post-condition-on-lazyseq/9444)

<div class="topic-metadata">

**Author:** [@raoul2000](https://clojureverse.org/u/raoul2000)\
**Replies:** 4\
**Last updated:** [October 16, 2022, 11:33am UTC](https://clojureverse.org/t/spec-and-post-condition-on-lazyseq/9444 "2022-10-16T11:33:38Z")

</div>

Hello, I’m trying to learn spec and during my experiments, I encountered a problem that hopefully someone will help me solve.Here it is : I want to use :pre and :post conditions on a function that will receive a list o…

---

## [Starting a new ClojureScript project in 2022. Setup suggestions](https://clojureverse.org/t/starting-a-new-clojurescript-project-in-2022-setup-suggestions/9222)

<div class="topic-metadata">

**Author:** [@interstar](https://clojureverse.org/u/interstar)\
**Replies:** 51\
**Last updated:** [August 30, 2022, 11:27pm UTC](https://clojureverse.org/t/starting-a-new-clojurescript-project-in-2022-setup-suggestions/9222 "2022-08-30T23:27:28Z")

</div>

I need to start a new ClojureScript project with the following properties : I want to write a ClojureScript app that runs purely in the browser. No need for a server. And eventually I want to compile it to a single JS…

---

## [Is there a compile-time check that a type that's stated as implementing a protocol actually implements it?](https://clojureverse.org/t/is-there-a-compile-time-check-that-a-type-thats-stated-as-implementing-a-protocol-actually-implements-it/9235)

<div class="topic-metadata">

**Author:** [@interstar](https://clojureverse.org/u/interstar)\
**Replies:** 1\
**Last updated:** [August 14, 2022, 3:40pm UTC](https://clojureverse.org/t/is-there-a-compile-time-check-that-a-type-thats-stated-as-implementing-a-protocol-actually-implements-it/9235 "2022-08-14T15:40:02Z")

</div>

The one thing I miss from Java is the ability to say “this type of thing implements these methods” and have the compiler alert me if it doesn’t. Given that Clojure has defprotocol / defrecord which kinda map to interfac…

---

## [Using Schema-like schemas in malli](https://clojureverse.org/t/using-schema-like-schemas-in-malli/8613)

<div class="topic-metadata">

**Author:** [@DrLjotsson](https://clojureverse.org/u/DrLjotsson)\
**Replies:** 6\
**Last updated:** [February 12, 2022, 8:08pm UTC](https://clojureverse.org/t/using-schema-like-schemas-in-malli/8613 "2022-02-12T20:08:05Z")

</div>

I’ve just refactored my reitit API to use malli instead of Clojure spec through spec-tools. However, I sorely missed the Schema-like syntax in malli. Even though the hiccup-like syntax in malli is more powerful, I like h…

---

## [Spec.alpha bug with sets and regular expression operators?](https://clojureverse.org/t/spec-alpha-bug-with-sets-and-regular-expression-operators/8592)

<div class="topic-metadata">

**Author:** [@clj2021](https://clojureverse.org/u/clj2021)\
**Replies:** 2\
**Last updated:** [January 31, 2022, 7:56pm UTC](https://clojureverse.org/t/spec-alpha-bug-with-sets-and-regular-expression-operators/8592 "2022-01-31T19:56:28Z")

</div>

Hi, I’m trying to validate the contents of a set for output options. It may contain :csv and/or :xlsx. When I try \> (require '\[clojure.spec.alpha :as spec\]) \> (spec/explain (spec/+ #{:csv :xlsx}) #{:any}) #{:any} - f…

---

## [Does Clojure spec supports Records?](https://clojureverse.org/t/does-clojure-spec-supports-records/8428)

<div class="topic-metadata">

**Author:** [@ACiep](https://clojureverse.org/u/ACiep)\
**Replies:** 2\
**Last updated:** [December 15, 2021, 6:51pm UTC](https://clojureverse.org/t/does-clojure-spec-supports-records/8428 "2021-12-15T18:51:07Z")

</div>

tl;dr - if not that’s ok but if it does then I want to show you strange behavior of using records and collections within spec/or (I haven’t tested yet if it is the same for other combining macros) Ok, It’s hard to expla…

---

## [Do you encapsulate domain entity maps?](https://clojureverse.org/t/do-you-encapsulate-domain-entity-maps/6147)

<div class="topic-metadata">

**Author:** [@shomiyamoto](https://clojureverse.org/u/shomiyamoto)\
**Replies:** 15\
**Last updated:** [July 15, 2020, 4:23am UTC](https://clojureverse.org/t/do-you-encapsulate-domain-entity-maps/6147 "2020-07-15T04:23:01Z")

</div>

Recently I found myself struggling with endless refactoring that results from the fact that spec’ed entity maps are referenced all over my codebase. I remembered this talk, You are in a maze of deeply nested maps, all al…

---

## [How do you tie your specs to your Document DB usage?](https://clojureverse.org/t/how-do-you-tie-your-specs-to-your-document-db-usage/6117)

<div class="topic-metadata">

**Author:** [@Webdev\_Tory](https://clojureverse.org/u/Webdev_Tory)\
**Replies:** 6\
**Last updated:** [July 6, 2020, 8:30am UTC](https://clojureverse.org/t/how-do-you-tie-your-specs-to-your-document-db-usage/6117 "2020-07-06T08:30:39Z")

</div>

When using a document database I am schemaless, meaning I no longer have an init.sql that I frequently consult to ensure I’m adding the right fields. One good answer, as mentioned by didibus, is to leverage Spec for this…

---

## [Why are specs not extensible?](https://clojureverse.org/t/why-are-specs-not-extensible/6128)

<div class="topic-metadata">

**Author:** [@den](https://clojureverse.org/u/den)\
**Replies:** 12\
**Last updated:** [June 22, 2020, 9:35am UTC](https://clojureverse.org/t/why-are-specs-not-extensible/6128 "2020-06-22T09:35:04Z")

</div>

One pattern stands out in many of my projects where my code tries to recognize data by its shape using clojure.spec.alpha/confrom. Once annotated, the conformed output goes into a recursive function that traverses and tr…

---

## [Using clojure.spec in ClojureScript SPA](https://clojureverse.org/t/using-clojure-spec-in-clojurescript-spa/5675)

<div class="topic-metadata">

**Author:** [@pyrmont](https://clojureverse.org/u/pyrmont)\
**Replies:** 1\
**Last updated:** [March 30, 2020, 6:16am UTC](https://clojureverse.org/t/using-clojure-spec-in-clojurescript-spa/5675 "2020-03-30T06:16:25Z")

</div>

I’m working on Pondent (repository), a posting utility written in ClojureScript and made available via GitHub Pages (app). After authorising with GitHub, a user can commit files to a repository they administer. The app i…

---

## [Predicate instant?](https://clojureverse.org/t/predicate-instant/5611)

<div class="topic-metadata">

**Author:** [@Webdev\_Tory](https://clojureverse.org/u/Webdev_Tory)\
**Replies:** 2\
**Last updated:** [March 13, 2020, 10:52pm UTC](https://clojureverse.org/t/predicate-instant/5611 "2020-03-13T22:52:00Z")

</div>

I need a cljc function for a spec to verify that a thing is an #inst; I see js/Date. things as well as back-end things doing this. Any suggestions?

---

## [Root – recursive UI resolution](https://clojureverse.org/t/root-recursive-ui-resolution/5488)

<div class="topic-metadata">

**Author:** [@den](https://clojureverse.org/u/den)\
**Replies:** 2\
**Last updated:** [March 5, 2020, 2:33pm UTC](https://clojureverse.org/t/root-recursive-ui-resolution/5488 "2020-03-05T14:33:32Z")

</div>

crosspost from r/clojure I’m finally open sourcing my project root. It’s been in development since March 2019 with a few breaks to ponder its design. The goal of root was to make everything as stupid (read decomplected)…

---

## [Generating values of stubbed fdef as a function of its arguments](https://clojureverse.org/t/generating-values-of-stubbed-fdef-as-a-function-of-its-arguments/5468)

<div class="topic-metadata">

**Author:** [@telekid](https://clojureverse.org/u/telekid)\
**Replies:** 2\
**Last updated:** [February 13, 2020, 10:10pm UTC](https://clojureverse.org/t/generating-values-of-stubbed-fdef-as-a-function-of-its-arguments/5468 "2020-02-13T22:10:07Z")

</div>

I’m wondering if it’s possible to generate values of a stubbed fdef such that they are a function of its arguments. Concrete example: In this gist, an outer function calls an inner function twice with the same value ( i)…

---

## [How to do realworld generating test with spec?](https://clojureverse.org/t/how-to-do-realworld-generating-test-with-spec/5254)

<div class="topic-metadata">

**Author:** [@ShiTianshu](https://clojureverse.org/u/ShiTianshu)\
**Replies:** 5\
**Last updated:** [December 26, 2019, 3:22am UTC](https://clojureverse.org/t/how-to-do-realworld-generating-test-with-spec/5254 "2019-12-26T03:22:05Z")

</div>

spec is easy to use for validation, because in this case specs are easy to write. basically you don’t really care about the value, just care about the type or data shape. But for generating test, I found, at least for me…

---

## [Spec/merge vs spec/and](https://clojureverse.org/t/spec-merge-vs-spec-and/5092)

<div class="topic-metadata">

**Author:** [@Daniel\_Fitzpatrick](https://clojureverse.org/u/Daniel_Fitzpatrick)\
**Replies:** 5\
**Last updated:** [November 14, 2019, 10:14pm UTC](https://clojureverse.org/t/spec-merge-vs-spec-and/5092 "2019-11-14T22:14:11Z")

</div>

Placing this under the Beginners section because I’m completely new to spec. What’s the difference between s/and & s/merge and when should I choose one over the other?

---

## [Hyphenate Clojure spec with underscored keys](https://clojureverse.org/t/hyphenate-clojure-spec-with-underscored-keys/5016)

<div class="topic-metadata">

**Author:** [@ilemming](https://clojureverse.org/u/ilemming)\
**Replies:** 3\
**Last updated:** [October 25, 2019, 1:23pm UTC](https://clojureverse.org/t/hyphenate-clojure-spec-with-underscored-keys/5016 "2019-10-25T13:23:19Z")

</div>

Very often I have to deal with maps of data that comes from DB and usually keys are underscored, e.g.: {:first\_thing "one", :second\_thing "two"} But also in the code these map keys get hyphenated. I wonder how you dea…

---

## [Deriving/generating specs from DB Schema](https://clojureverse.org/t/deriving-generating-specs-from-db-schema/5017)

<div class="topic-metadata">

**Author:** [@ilemming](https://clojureverse.org/u/ilemming)\
**Replies:** 0\
**Last updated:** [October 24, 2019, 8:41pm UTC](https://clojureverse.org/t/deriving-generating-specs-from-db-schema/5017 "2019-10-24T20:41:36Z")

</div>

Do we have a nice way to generate specs for DB Tables, e.g. Postgres based on table DDLs? Maybe someone has written libraries and such?

---

## [Why aren't specs pure data?](https://clojureverse.org/t/why-arent-specs-pure-data/4950)

<div class="topic-metadata">

**Author:** [@devth](https://clojureverse.org/u/devth)\
**Replies:** 6\
**Last updated:** [October 18, 2019, 5:12pm UTC](https://clojureverse.org/t/why-arent-specs-pure-data/4950 "2019-10-18T17:12:10Z")

</div>

Disclaimer: I don’t mean for this to seem controversial or offensive and am genuinely curious. I have no idea what I’m doing. I’m probably wrong, and will keep it short. tldr: What if “Specs as data” was the primary des…

---

## [Applying Spec-based generative testing to a transformation pipeline - tips and lessons learned](https://clojureverse.org/t/applying-spec-based-generative-testing-to-a-transformation-pipeline-tips-and-lessons-learned/4926)

<div class="topic-metadata">

**Author:** [@HolyJak](https://clojureverse.org/u/HolyJak)\
**Replies:** 2\
**Last updated:** [October 5, 2019, 8:10am UTC](https://clojureverse.org/t/applying-spec-based-generative-testing-to-a-transformation-pipeline-tips-and-lessons-learned/4926 "2019-10-05T08:10:21Z")

</div>

I have written about our lessons-learned from Spec-based generative testing and would very much appreciate feedback (and perhaps other tips for such testing): Having the computer generate tests for you, trying tens of d…

---

## [Portability of ns keywords](https://clojureverse.org/t/portability-of-ns-keywords/4873)

<div class="topic-metadata">

**Author:** [@Webdev\_Tory](https://clojureverse.org/u/Webdev_Tory)\
**Replies:** 5\
**Last updated:** [September 21, 2019, 10:19am UTC](https://clojureverse.org/t/portability-of-ns-keywords/4873 "2019-09-21T10:19:50Z")

</div>

I’m hoping that someone here might know a good solution or tell me I’m wrong, but otherwise here goes for a conversation starter: Namespaced keywords seem like a great idea in theory, but are not portable (not even with…

---

## [Spec: Best practices for raw vs cleaned input data validation?](https://clojureverse.org/t/spec-best-practices-for-raw-vs-cleaned-input-data-validation/4742)

<div class="topic-metadata">

**Author:** [@HolyJak](https://clojureverse.org/u/HolyJak)\
**Replies:** 8\
**Last updated:** [August 21, 2019, 4:49pm UTC](https://clojureverse.org/t/spec-best-practices-for-raw-vs-cleaned-input-data-validation/4742 "2019-08-21T16:49:07Z")

</div>

I would appreciate your input on the following problem: We use Spec to 1) Document what data flows through our code (annotating key transformation functions with it, not just the input and output ones), 2) Auto-generate …

---

## [How to define and use a macro in both CLJ and CLJS?](https://clojureverse.org/t/how-to-define-and-use-a-macro-in-both-clj-and-cljs/2896)

<div class="topic-metadata">

**Author:** [@DjebbZ](https://clojureverse.org/u/DjebbZ)\
**Replies:** 6\
**Last updated:** [July 10, 2019, 9:39pm UTC](https://clojureverse.org/t/how-to-define-and-use-a-macro-in-both-clj-and-cljs/2896 "2019-07-10T21:39:21Z")

</div>

Hello, After many (many many) trials and errors, I’ve finally managed to define a macro that I can use in a CLJC file, for both a CLJ/JVM project and a CLJS/Browser project. This post started as a question that I rewrot…

---

## [Spec: entity id list and entity consistency?](https://clojureverse.org/t/spec-entity-id-list-and-entity-consistency/4294)

<div class="topic-metadata">

**Author:** [@andersmurphy](https://clojureverse.org/u/andersmurphy)\
**Replies:** 7\
**Last updated:** [June 12, 2019, 11:53am UTC](https://clojureverse.org/t/spec-entity-id-list-and-entity-consistency/4294 "2019-06-12T11:53:04Z")

</div>

Hi, I was wondering if anyone knows the answer or could point me at a resource that would help me solve this problem. I want to generate a list of entity-ids and then a list of entities, the catch is I want each entity …

---

## [Composing specs with s/keys and s/and](https://clojureverse.org/t/composing-specs-with-s-keys-and-s-and/4232)

<div class="topic-metadata">

**Author:** [@tomc](https://clojureverse.org/u/tomc)\
**Replies:** 2\
**Last updated:** [May 7, 2019, 3:37pm UTC](https://clojureverse.org/t/composing-specs-with-s-keys-and-s-and/4232 "2019-05-07T15:37:30Z")

</div>

I haven’t been able to find much online about composing map specs like the following: (require '\[clojure.spec.alpha :as s\]) (s/def ::m1 (s/keys :req \[::a ::b\])) (s/def ::m2 (s/and ::m1 (s/keys :req \[::c ::d\]))) This wo…

---

## [Announcing: defn-spec](https://clojureverse.org/t/announcing-defn-spec/4089)

<div class="topic-metadata">

**Author:** [@danielcompton](https://clojureverse.org/u/danielcompton)\
**Replies:** 1\
**Last updated:** [April 1, 2019, 5:27pm UTC](https://clojureverse.org/t/announcing-defn-spec/4089 "2019-04-01T17:27:43Z")

</div>

Hi folks I’ve created a new library called defn-spec. It lets you define Clojure specs inline with your function definitions. It reuses the design (and much of the implementation) of Schema, so if you’re familiar with t…

---

## [How to be agile with spec?](https://clojureverse.org/t/how-to-be-agile-with-spec/3976)

<div class="topic-metadata">

**Author:** [@Webdev\_Tory](https://clojureverse.org/u/Webdev_Tory)\
**Replies:** 5\
**Last updated:** [March 16, 2019, 4:59pm UTC](https://clojureverse.org/t/how-to-be-agile-with-spec/3976 "2019-03-16T16:59:26Z")

</div>

Having just watched the classic Halloway introduction of Spec, “Agility & Robustness”, I thought on my last use of spec. I used it for my interface between my cljs and clj. I created specs in a cljc namespace, and used p…

[Next page](https://clojureverse.org/tag/clojure-spec/10.md?match_all_tags=true&page=1&tags%5B%5D=clojure_spec)
