Created
March 31, 2017 17:20
-
-
Save jcf/54af71b2191bdb8e1151366d03075ac0 to your computer and use it in GitHub Desktop.
In a couple of minutes I've got a first version of validating pull syntax via clojure.spec?!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(s/def ::attr-name | |
qualified-keyword?) | |
(s/def ::recursion-limit | |
(s/or :num pos-int? | |
:str #{"..."})) | |
(s/def ::wildcard | |
(s/or :str #{"*"} | |
:sym #{'*})) | |
(s/def ::limit | |
(s/or :str #{"limit"} | |
:sym #{'limit})) | |
(s/def ::limit-expr | |
(s/cat :limit ::limit | |
:attr-name ::attr-name | |
:amount (s/or :num pos-int? | |
:nil nil?))) | |
(s/def ::default-expr | |
(s/cat :default (s/or :str #{"default"} | |
:sym #{'default}) | |
:attr-name ::attr-name | |
:value any?)) | |
(s/def ::attr-expr | |
(s/or :limit ::limit-expr | |
:default-expr ::default-expr)) | |
(s/def ::map-spec | |
(s/map-of (s/or :attr-name ::attr-name | |
:limit-expr ::limit-expr) | |
(s/or :query ::query | |
:recursion-limit ::recursion-limit))) | |
(s/def ::attr-spec | |
(s/or :attr-name ::attr-name | |
:wildcard ::wildcard | |
:map-spec ::map-spec | |
:attr-expr ::attr-expr)) | |
(s/def ::query | |
(s/+ ::attr-spec)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's not production ready, but this took me just a few minutes to throw together. Wow.