Comments (4)
@ikitommi Thanks very much for the idea!
I'm going to think a bit about whether this is something that fits well into Expound.
One concern is that I'm wondering if there a way to consistently get all keys for Clojure and Clojurescript in the case where there are multi-specs that use keys
. There's more detail in this thread. Thank you for linking to the spec-tools code - I haven't yet tried it out for the multi-spec case, but it may solve this issue. I have also created https://dev.clojure.org/jira/browse/CLJ-2294 to ask for support in spec for this use case.
My second concern is how to integrate this into Expound. Currently Expound doesn't alter how spec validation works, it just replaces the printer. I could add options to the expound
function, but changing validation in the case of instrumentation, or using explain
(which are both supported) would require implementing wrappers around instrument
, explain
, assert
, etc. This isn't necessary a bad thing (I'm considering doing this for Expound beta anyway), but I just want to think about what this would entail.
For the implementation, I think Expound would either need to modify the way spec validates data, or perhaps do a second pass of validation that specifically look for this case.
Anyway, I'll think more about this. I certainly agree it would be useful (I'd use it!) but I'm not sure if it should be in Expound or another library.
from expound.
Hi. I poked with the strictly-specking that figwheel is using. Did a PR to make it work with Clojure 1.9.0. It does all the things I would like to have, but sadly, requires a custom ss/strict-keys
to be used to get the errors for extra keys.
If the config maps were only 1-level deep, I could let the users define the spec as vanilla s/keys
and convert them behind the scenes to ss/strict-keys
and run validation against that. But can't do this with nested maps without mutating the Spec registry. Bummer. Something like local-keys
might help here. I might do that, and push it to spec-tools or to strictly-specking.
I think the custom explain
you mentioned isn't easy either. For s/keys
, the s/explain*
recurs to normal s/explain
. Things like CLJ-2116 and CLJ-2251 would help here.
Hopefully you figure out a way to do this, maybe expound could use strictly-specking? Or merge the libs? I'll post here if I get something helpful in spec-tools (doesn't do multi-specs yet btw).
from expound.
@ikitommi @bhauman just released spell-spec. Would this work for your use case here?
from expound.
This is it. Will start integrating that into spec-tools.
from expound.
Related Issues (20)
- Error reports returned as :cause string in an exception when produced by instrumentation within generative testing HOT 11
- allow passing options map to expound/expound-str HOT 1
- Improve grouping of spec errors HOT 2
- Unnecessary dependency on `cider-nrepl` HOT 1
- Regression of #3 HOT 4
- Easier editing of error messages
- `printer` has invalid spec HOT 2
- "Cannot convert path" on instrumentation failures in the wild HOT 4
- (cljs.spec.test.alpha/instrument) breaks expound due to wrong arity HOT 4
- should expound work anywhere s/explain works? - clojurescript error HOT 7
- Error in :ret check when using with Orchestra 2020.07.12-1 HOT 5
- Internal error in `lift-singleton-groups` when having a datomic db value in fn args HOT 13
- Crash bug when printing, if a datomic db is present and the spec fails HOT 19
- Feature inquiry: a convenience function for validating a value against a spec HOT 4
- Wrapped `s/keys` does not properly display unqualified keyword specs HOT 5
- ClassCastException from `expound-str` when running in AWS Lambda HOT 9
- Small *print-length* and/or *print-level* sometimes yield NPE HOT 5
- PersistentList cannot be cast to class Named HOT 3
- proposal : defmsg equivalent for arbitrary predicates HOT 15
- optional include location of the spec error in the message. HOT 2
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 expound.