dog-and-duck.quack.picky
Fault-finder for ActivityPub documents.
Generally, each -faults
function will return:
nil
if no faults were found;- a sequence of fault objects if faults were found.
Each fault object shall have the properties:
:@context
whose value shall be the URL of a document specifying this vocabulary;:type
whose value shall beFault
;:severity
whose value shall be one ofinfo
,minor
,should
,must
orcritical
;:fault
whose value shall be a unique token representing the particular fault type;:narrative
whose value shall be a natural language description of the fault type.
Note that the reason for the :fault
property is to be able to have a well known place, linked to from the @context URL, which allows narratives for each fault type to be served in as many natural languages as possible.
The idea further is that it should ultimately be possible to serialise a fault report as a document which in its own right conforms to the ActivityStreams spec.
accept-required-properties
As base-activity-required-properties, except that the type of the object is restricted.
activity-required-properties
Properties activities should have, keyed by activity type. Values are maps of the format of base-activity-required-properties
, q.v.
activity-type-faults
(activity-type-faults x)
(activity-type-faults x type)
Return a list of faults found in the activity x
; if type
is also specified, it should be a string naming a specific activity type for which checks should be performed.
Some specific activity types have specific requirements which are not requirements.
actor-faults
(actor-faults x)
Return a list of faults found in actor x
, or nil
if none are.
base-activity-required-properties
Properties most activities should have. Values are validating functions, each.
See https://www.w3.org/TR/activitystreams-vocabulary/#dfn-activity
coll-object-reference-or-fault
(coll-object-reference-or-fault value expected-type severity token)
As object-reference-or-fault, except value
argument may also be a list of objects and/or object references.
intransitive-activity-required-properties
Properties intransitive activities should have.
See https://www.w3.org/TR/activitystreams-vocabulary/#dfn-intransitiveactivity
link-faults
(link-faults x)
A link object is required to have an href
property. It may have all of rel
| mediaType
| name
| hreflang
| height
| width
| preview
but I think they’re all optional.
object-faults
(object-faults x)
(object-faults x expected-type)
Return a list of faults found in object x
, or nil
if none are.
If expected-type
is also passed, verify that x
has expected-type
. expected-type
may be passed as a string or as a set of strings.
object-reference-or-faults
(object-reference-or-faults value expected-type severity token)
If this value
is either
- an object of
expected-type
; - a URI referencing an object of
expected-type
; or - a link object referencing an object of
expected-type
and no faults are returned from validating the linked object, then return nil
; else return a sequence comprising a fault object with this severity
and token
, prepended to the faults returned.
As with has-type-or-fault
(q.v.), expected-type
may be passed as a string or as a set of strings.
NOTE THAT if *reify-refs*
is false
, referenced objects will not actually be checked.
persistent-object-faults
(persistent-object-faults x)
(persistent-object-faults x types severity token)
Return a list of faults found in persistent object x
, or nil
if none are.
string-or-fault
(string-or-fault value severity token)
(string-or-fault value severity token pattern)
If this value
is not a string, return a fault object with this severity
and token
, else nil
. If pattern
is also passed, it is expected to be a Regex, and the fault object will be returned unless value
matches the pattern
.
uri-or-fault
(uri-or-fault u severity if-missing-token)
(uri-or-fault u severity if-missing-token if-invalid-token)
If u
is not a valid URI, return a fault object with this severity
and if-invalid-token
. If it’s nil
, return a fault object with this severity
and if-missing-token
. Otherwise return nil.