Closed alza-bitz closed 5 years ago
Hi again,
Whatever the underlying issue is, it seems to be affecting data-spec/or
as well. For example, if I redefine widget-spec
as:
(def widget-spec
(std/spec
{:name ::widget-spec
:spec {:sub-widgets [(std/or
{:sub-widget-a sub-widget-a-spec
:sub-widget-b sub-widget-b-spec
:sub-widget-c sub-widget-c-spec})]}}))
And try again:
(st/encode widget-spec (gen/generate (s/gen widget-spec)) st/string-transformer)
I get similar results:
{:sub-widgets [{:b-prop 228404} {:c-prop 766} {:c-prop 1} {:a-prop "1573"} {:c-prop 33686636}]}
Since the data-spec/or
issue is separate to the regex ops issue (and the results are slightly different), I've created a separate issue for that one: https://github.com/metosin/spec-tools/issues/147
Fixed by #148.
Hi there,
I was just wondering if the spec regex ops on sequences are supported? I am seeing some interesting results when I try and perform encoding.
For example, given the following example data specs:
If I try and generate some sample data using the data spec, all is good and I see the regex op rules and ordering being adhered to for the sequence:
However, if I then try to perform encoding, for example encoding to strings, I see inconsistent results - some data in the sequence is encoded correctly, but some is left as-is:
I was wondering whether this should be expected to work or not? (since
gen/generate
works, it's just the encoding that doesn't and is therefore possibly a bug?)Thanks!