Skip to content

Commit d131905

Browse files
committed
remove ::simple-parser type property
1 parent 4990365 commit d131905

File tree

2 files changed

+30
-23
lines changed

2 files changed

+30
-23
lines changed

src/malli/core.cljc

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,8 @@
120120

121121
ParserInfo
122122
(-parser-info [this]
123-
(when (schema? this)
124-
(if (-ref-schema? this)
125-
(-parser-info (-deref this))
126-
(when (-> this -parent -type-properties ::simple-parser)
127-
{:simple-parser true}))))
123+
(when (-ref-schema? this)
124+
(-parser-info (-deref this))))
128125

129126
RegexSchema
130127
(-regex-op? [_] false)
@@ -752,7 +749,7 @@
752749
(-from-ast [parent ast options] (from-ast parent ast options))
753750
IntoSchema
754751
(-type [_] type)
755-
(-type-properties [_] (assoc type-properties ::simple-parser true))
752+
(-type-properties [_] type-properties)
756753
(-properties-schema [_ _])
757754
(-children-schema [_ _])
758755
(-into-schema [parent properties children options]
@@ -789,6 +786,8 @@
789786
(-keep [_])
790787
(-get [_ _ default] default)
791788
(-set [this key _] (-fail! ::non-associative-schema {:schema this, :key key}))
789+
ParserInfo
790+
(-parser-info [_] {:simple-parser true})
792791
#?@(:cljs [IPrintWithWriter (-pr-writer [this writer opts] (pr-writer-schema this writer opts))])))))
793792
#?@(:cljs [IPrintWithWriter (-pr-writer [this writer opts] (pr-writer-into-schema this writer opts))])))))
794793

@@ -820,11 +819,10 @@
820819
cache (-create-cache options)
821820
transforming-parser (delay
822821
(let [transforming-parsers (or (when-some [[_ i] (find properties :parse/transforming-child)]
823-
(or (when (= :none i)
824-
[])
825-
(when-not (and (nat-int? i) (< i (count children)))
826-
(-fail! ::and-schema-invalid-parse-property {:schema @form}))
827-
[i]))
822+
(cond
823+
(= :none i) []
824+
(and (nat-int? i) (< i (count children))) [i]
825+
:else (-fail! ::and-schema-invalid-parse-property {:schema @form})))
828826
(into []
829827
(keep-indexed
830828
(fn [i c]
@@ -1088,7 +1086,7 @@
10881086
(-from-ast [parent ast options] (-from-child-ast parent ast options))
10891087
IntoSchema
10901088
(-type [_] :not)
1091-
(-type-properties [_] {::simple-parser true})
1089+
(-type-properties [_])
10921090
(-properties-schema [_ _])
10931091
(-children-schema [_ _])
10941092
(-into-schema [parent properties children options]
@@ -1122,6 +1120,8 @@
11221120
(-keep [_])
11231121
(-get [_ key default] (get children key default))
11241122
(-set [this key value] (-set-assoc-children this key value))
1123+
ParserInfo
1124+
(-parser-info [_] {:simple-parser true})
11251125
#?@(:cljs [IPrintWithWriter (-pr-writer [this writer opts] (pr-writer-schema this writer opts))]))))
11261126
#?@(:cljs [IPrintWithWriter (-pr-writer [this writer opts] (pr-writer-into-schema this writer opts))])))
11271127

@@ -1632,7 +1632,7 @@
16321632
(-from-ast [parent ast options] (-into-schema parent (:properties ast) (:values ast) options))
16331633
IntoSchema
16341634
(-type [_] :enum)
1635-
(-type-properties [_] {::simple-parser true})
1635+
(-type-properties [_])
16361636
(-into-schema [parent properties children options]
16371637
(-check-children! :enum properties children 1 nil)
16381638
(let [children (vec children)
@@ -1667,6 +1667,8 @@
16671667
(-keep [_])
16681668
(-get [_ key default] (get children key default))
16691669
(-set [this key value] (-set-assoc-children this key value))
1670+
ParserInfo
1671+
(-parser-info [_] {:simple-parser true})
16701672
#?@(:cljs [IPrintWithWriter (-pr-writer [this writer opts] (pr-writer-schema this writer opts))]))))
16711673
#?@(:cljs [IPrintWithWriter (-pr-writer [this writer opts] (pr-writer-into-schema this writer opts))])))
16721674

@@ -1677,7 +1679,7 @@
16771679
(-from-ast [parent ast options] (-from-value-ast parent ast options))
16781680
IntoSchema
16791681
(-type [_] :re)
1680-
(-type-properties [_] {::simple-parser true})
1682+
(-type-properties [_])
16811683
(-properties-schema [_ _])
16821684
(-children-schema [_ _])
16831685
(-into-schema [parent properties [child :as children] options]
@@ -1719,6 +1721,8 @@
17191721
(-keep [_])
17201722
(-get [_ key default] (get children key default))
17211723
(-set [this key value] (-set-assoc-children this key value))
1724+
ParserInfo
1725+
(-parser-info [_] {:simple-parser true})
17221726
#?@(:cljs [IPrintWithWriter (-pr-writer [this writer opts] (pr-writer-schema this writer opts))]))))
17231727
#?@(:cljs [IPrintWithWriter (-pr-writer [this writer opts] (pr-writer-into-schema this writer opts))])))
17241728

@@ -1729,7 +1733,7 @@
17291733
(-from-ast [parent ast options] (-from-value-ast parent ast options))
17301734
IntoSchema
17311735
(-type [_] :fn)
1732-
(-type-properties [_] {::simple-parser true})
1736+
(-type-properties [_])
17331737
(-into-schema [parent properties children options]
17341738
(-check-children! :fn properties children 1 1)
17351739
(let [children (vec children)
@@ -1766,6 +1770,8 @@
17661770
(-keep [_])
17671771
(-get [_ key default] (get children key default))
17681772
(-set [this key value] (-set-assoc-children this key value))
1773+
ParserInfo
1774+
(-parser-info [_] {:simple-parser true})
17691775
#?@(:cljs [IPrintWithWriter (-pr-writer [this writer opts] (pr-writer-schema this writer opts))]))))
17701776
#?@(:cljs [IPrintWithWriter (-pr-writer [this writer opts] (pr-writer-into-schema this writer opts))])))
17711777

@@ -2071,7 +2077,7 @@
20712077
guard (conj (from-ast guard))) options))
20722078
IntoSchema
20732079
(-type [_] :=>)
2074-
(-type-properties [_] {::simple-parser true})
2080+
(-type-properties [_])
20752081
(-into-schema [parent properties children {::keys [function-checker] :as options}]
20762082
(-check-children! :=> properties children 2 3)
20772083
(let [[input output guard :as children] (-vmap #(schema % options) children)
@@ -2152,14 +2158,16 @@
21522158
(-keep [_])
21532159
(-get [_ key default] (get children key default))
21542160
(-set [this key value] (-set-assoc-children this key value))
2161+
ParserInfo
2162+
(-parser-info [_] {:simple-parser true})
21552163
#?@(:cljs [IPrintWithWriter (-pr-writer [this writer opts] (pr-writer-schema this writer opts))]))))
21562164
#?@(:cljs [IPrintWithWriter (-pr-writer [this writer opts] (pr-writer-into-schema this writer opts))])))
21572165

21582166
(defn -function-schema [_]
21592167
^{:type ::into-schema}
21602168
(reify IntoSchema
21612169
(-type [_] :function)
2162-
(-type-properties [_] {::simple-parser true})
2170+
(-type-properties [_])
21632171
(-properties-schema [_ _])
21642172
(-children-schema [_ _])
21652173
(-into-schema [parent properties children {::keys [function-checker] :as options}]
@@ -2224,6 +2232,8 @@
22242232
(-keep [_])
22252233
(-get [_ key default] (get children key default))
22262234
(-set [this key value] (-set-assoc-children this key value))
2235+
ParserInfo
2236+
(-parser-info [_] {:simple-parser true})
22272237
#?@(:cljs [IPrintWithWriter (-pr-writer [this writer opts] (pr-writer-schema this writer opts))]))))
22282238
#?@(:cljs [IPrintWithWriter (-pr-writer [this writer opts] (pr-writer-into-schema this writer opts))])))
22292239

test/malli/core_test.cljc

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2386,8 +2386,7 @@
23862386
:json-schema/type "integer"
23872387
:json-schema/format "int64"
23882388
:json-schema/minimum 6
2389-
:gen/gen generate-over6
2390-
::m/simple-parser true}
2389+
:gen/gen generate-over6}
23912390
(m/type-properties over6)))
23922391
(is (= {:json-schema/example 42}
23932392
(m/properties over6))))))
@@ -2418,8 +2417,7 @@
24182417
:decode/string mt/-string->long
24192418
:json-schema/type "integer"
24202419
:json-schema/format "int64"
2421-
:json-schema/minimum 6
2422-
::m/simple-parser true}
2420+
:json-schema/minimum 6}
24232421
(m/type-properties schema)))
24242422
(is (= {:value 6}
24252423
(m/properties schema))))))
@@ -2436,8 +2434,7 @@
24362434
:decode/string mt/-string->long
24372435
:json-schema/type "integer"
24382436
:json-schema/format "int64"
2439-
:json-schema/minimum 42
2440-
::m/simple-parser true}
2437+
:json-schema/minimum 42}
24412438
(m/type-properties schema)))
24422439
(is (= {:value 42}
24432440
(m/properties schema)))))))))

0 commit comments

Comments
 (0)