Tactical commit before attempting recursive validation

This commit is contained in:
Simon Brooke 2023-01-10 20:36:00 +00:00
parent a185edb9da
commit 440ea003e2
8 changed files with 39 additions and 28 deletions

2
.gitignore vendored
View file

@ -15,3 +15,5 @@ pom.xml.asc
.calva .calva
.clj-kondo .clj-kondo
.lsp .lsp
docs/samples/

View file

@ -35,6 +35,8 @@ The full range of command-line switches is as follows:
Note, though, that internationalisation files for languages other than British English have not yet been written, and that one is not complete. Note, though, that internationalisation files for languages other than British English have not yet been written, and that one is not complete.
Note also that reification is not, at the time of writing, working.
The following severity levels are understood: The following severity levels are understood:
0. `info` things which are not actuallys fault, but issues noted during 0. `info` things which are not actuallys fault, but issues noted during
@ -48,7 +50,6 @@ The following severity levels are understood:
4. `critical` instances where I believe the fault means that 4. `critical` instances where I believe the fault means that
the object cannot be meaningfully processed. the object cannot be meaningfully processed.
## Examples ## Examples
... ...
@ -59,23 +60,12 @@ Full documentation is [here](https://simon-brooke.github.io/dog-and-duck/).
### Bugs ### Bugs
... Many. Ducks like bugs.
### Any Other Sections
### That You Think
### Might be Useful
## License ## License
Copyright © 2023 FIXME Copyright © 2023 Simon Brooke
This program and the accompanying materials are made available under the This Source Code is made available under GNU General Public License as published by
terms of the Eclipse Public License 2.0 which is available at
http://www.eclipse.org/legal/epl-2.0.
This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the Eclipse
Public License, v. 2.0 are satisfied: GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or (at your the Free Software Foundation, either version 2 of the License, or (at your
option) any later version, with the GNU Classpath Exception which is available option) any later version.
at https://www.gnu.org/software/classpath/license.html.

14
scan-test-docs.sh Executable file
View file

@ -0,0 +1,14 @@
#!/bin/bash
docs=../dog-and-duck/resources/activitystreams-test-documents/
for file in ${docs}/*.json
do
name=`basename ${file} | sed s/json$/html/`
echo ${name}
java -jar target/uberjar/quack-0.1.0-SNAPSHOT-standalone.jar \
-i ${file} \
-o "docs/samples/${name}" \
-f html
done

View file

@ -11,7 +11,7 @@
[dog-and-duck.quack.utils :refer [filter-severity safe-keyword]] [dog-and-duck.quack.utils :refer [filter-severity safe-keyword]]
[hiccup.core :refer [html]] [hiccup.core :refer [html]]
[scot.weft.i18n.core :refer [*config* [scot.weft.i18n.core :refer [*config*
get-message get-message
parse-accept-language-header]] parse-accept-language-header]]
[trptr.java-wrapper.locale :as locale]) [trptr.java-wrapper.locale :as locale])
(:gen-class)) (:gen-class))
@ -34,8 +34,8 @@
(def ^:const stylesheet-url (def ^:const stylesheet-url
;; TODO: fix this to github pages before go live ;; TODO: fix this to github pages before go live
;;"https://simon-brooke.github.io/quack/style.css" ;;"https://simon-brooke.github.io/quack/css/style.css"
"resources/public/css/style.css") "../css/style.css")
(def cli-options (def cli-options
;; An option with a required argument ;; An option with a required argument
@ -116,20 +116,18 @@
second) second)
(catch Exception _ nil))])) (catch Exception _ nil))]))
(defn- output-html-text-analysed (defn- output-html-text-analysed
[options] [options]
[:div [:div
{:class "text-analysed"} {:class "text-analysed"}
[:h2 :text-analysed] [:h2 (get-message :text-analysed)]
[:pre {:class "ft-syntax-highlight" [:pre {:class "ft-syntax-highlight"
:data-syntax "javascript" :data-syntax "javascript"
:data-syntax-theme "bootstrap" :data-syntax-theme "bootstrap"
:data-ui-theme "light"} :data-ui-theme "light"}
(with-out-str (with-out-str
(json/pprint (slurp
(read-str (:input options)))]])
(slurp
(:input options)))))]])
(defn output-html (defn output-html
[faults options] [faults options]

View file

@ -419,7 +419,7 @@
:if-invalid [:must :invalid-units] :if-invalid [:must :invalid-units]
;; the narrative says that `anyURI`, but actually unless it's a recognised ;; the narrative says that `anyURI`, but actually unless it's a recognised
;; unit the property is useless. These are the units explicitly specified. ;; unit the property is useless. These are the units explicitly specified.
:validator (fn [pv] (#{"cm" "feet" "inches" "km" "m" "miles"} pv))} :validator (fn [pv] (truthy? (#{"cm" "feet" "inches" "km" "m" "miles"} pv)))}
:updated {:functional true :updated {:functional true
:if-invalid [:must :invalid-updated] :if-invalid [:must :invalid-updated]
:validator xsd-date-time?} :validator xsd-date-time?}
@ -460,7 +460,7 @@
;; from an 'or-faults' function which did not ;; from an 'or-faults' function which did not
;; return faults ;; return faults
(fault-list? r) (concat f r) (fault-list? r) (concat f r)
(false? r) (list f) (false? r) f
:else (doall :else (doall
(warn "Unexpected return value from validator" (warn "Unexpected return value from validator"
{:return r {:return r

View file

@ -13,4 +13,11 @@
(second (:if-missing %))) (second (:if-missing %)))
(vals object-expected-properties)))) (vals object-expected-properties))))
found (read-string (slurp (str "resources/i18n/" language ".edn")))] found (read-string (slurp (str "resources/i18n/" language ".edn")))]
(sort (remove found tokens)))) (sort (remove found tokens))))
;; (def f {:arguments {:reports ({:@context "https://simon-brooke.github.io/dog-and-duck/codox/Validation_Faults.html",
;; :id "https://illuminator.local/fault/25785:1673378166063", :type "Fault", :severity :should, :fault :no-context, :narrative "Section 3 of the ActivityPub specification states Implementers SHOULD include the ActivityPub context in their object definitions`."}
;; {:@context "https://simon-brooke.github.io/dog-and-duck/codox/Validation_Faults.html",
;; :id "https://illuminator.local/fault/25785:1673378166063", :type "Fault", :severity :minor, :fault :no-id-transient, :narrative "The ActivityPub specification allows objects without `id` fields only if they are intentionally transient; even so it is preferred that the object should have an explicit null id."}
;; ({:@context "https://simon-brooke.github.io/dog-and-duck/codox/Validation_Faults.html",
;; :id "https://illuminator.local/fault/25785:1673378166069", :type "Fault", :severity :must, :fault :invalid-type, :narrative "invalid-type"})), :severity :info}})