stathissideris / spec-provider

Infer Clojure specs from sample data. Inspired by F#'s type providers.
519 stars 22 forks source link

Support for `bigdec?` #15

Closed pfeodrippe closed 6 years ago

pfeodrippe commented 6 years ago

Bigdec is treated as any?, maybe it's as easy as add it to provider, gonna check it when I have some time.

;; using
(provider/infer-specs data :eita/danado)

;; where data is (after pprint)
({:principal 2.589383192884270087M,
  :start
  #object[org.joda.time.DateTime 0x1168723c "2011-01-01T00:00:00.000Z"],
  :end
  #object[org.joda.time.DateTime 0x537ef638 "2011-01-01T00:00:00.000Z"]}
 {:principal -474.192376784456429913M,
  :start
    #object[org.joda.time.DateTime 0x2417893b "2011-01-02T00:00:00.000Z"]))

;; and inferred spec is
((clojure.spec.alpha/def :eita/end clojure.core/any?)
 (clojure.spec.alpha/def :eita/start clojure.core/any?)
 (clojure.spec.alpha/def :eita/principal clojure.core/any?)
 (clojure.spec.alpha/def
  :eita/danado
  (clojure.spec.alpha/keys
   :req-un
   [:eita/principal :eita/start]
   :opt-un
   [:eita/end])))

Also, as a bonus, how could I support dates of the type org.joda.time.DateTime?

pfeodrippe commented 6 years ago

Solved