Comments (2)
Hi. You need to wrap Specs into Spec Records as clojure.spec
doesn't support runtime conforming and core Specs can't be extended. There is a Issue describing why and a patch to fix it. Go vote it up.
I don't think we are interested in turning spec into a transformation engine via conformers, so I suspect we are probably not interested. However, I'll leave it for Rich to assess.
Before / if ever that is resolved, instead of:
(require '[spec-tools.core :as st])
(require '[clojure.spec.alpha :as s])
(s/def ::attr #{"value"})
(s/def ::has-key (s/keys :opt [::attr]))
(st/conform
::has-key
#:noextrakey.clj.core
{:attr "value"
:other-attr "still-valid?"}
spec-tool/fail-on-extra-keys-conforming)
; #:noextrakey.clj.core{:attr "value", :other-attr "still-valid?"}
you need to:
(require '[spec-tools.core :as st])
(require '[clojure.spec.alpha :as s])
(s/def ::attr #{"value"})
(s/def ::has-key (st/spec (s/keys :opt [::attr])))
(st/explain
::has-key
#:noextrakey.clj.core
{:attr "value"
:other-attr "still-valid?"}
spec-tool/fail-on-extra-keys-conforming)
from spec-tools.
Alright, that's clear. Thanks!
from spec-tools.
Related Issues (20)
- ArityException Wrong number of args (2) passed to: clojure.lang.PersistentVector HOT 2
- StackOverflow when creating or utilising spec-tools with self referencing spec HOT 2
- ClassCastException using transformers
- Correctly generate Swagger2 for specs using int-in HOT 4
- ds/spec namespaced keys not prefixed with name HOT 4
- multi-spec -> swagger returns empty map
- strip-extra-keys-transformer not working with s/or if ors predicates are non- map validating specs
- s/keys + clojure.core/or -> swagger returns or args as required
- json-transformer not working correctly with set-specs HOT 1
- Coerce JS objects? HOT 2
- `spec-tools.transform/string->date` and `date->string` fail roundtrip for some dates
- `spec-tools.data-spec/spec` has a wrong assert
- s/explain-data throws exception for s/map-of spec with a s/or key HOT 1
- Unable to parse spec with s/nonconforming HOT 1
- `select-spec` removing keys when using `s/or`
- newer version doesn't support list in data spec
- In OpenAPI 3.0.x, Cannot use null type
- Invalid JSON Schema type generated for `s/tuple`
- `st/strip-extra-keys-transformer` not handling merged `s/or`
- Inconsistent results from s/valid? and s/explain when trying to spec list of values
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spec-tools.