dog-and-duck.quack.picky.objects
TODO: write docs
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.
maybe-reify
If *reify-refs*
is true
, return the object at this target
URI. Returns nil
if
*reify-refs*
is false;- the object was not found;
- access to the object was not permitted.
Consequently, use with care.
maybe-reify-or-faults
(maybe-reify-or-faults value expected-type severity token)
If *reify-refs*
is true
, runs basic checks on the object at this target
URI, if it is found, or a list containing a fault object with this severity
and token
if it is not.
object-expected-properties
Requirements of properties of object, cribbed from https://www.w3.org/TR/activitystreams-vocabulary/#properties
Note the following sub-key value types:
:collection
opposite of:functional
: if true, value should be a collection (in the Clojure sense), not a single object;:functional
if true, value should be a single object; if false, may be a single object or a sequence of objects, but each must pass validation checks;:if-invalid
a sequence of two keywords, first indicating severity, second being a message key;:if-missing
a sequence of two keywords, first indicating severity, second being a message key;:required
a boolean, or a function of one argument returning a boolean, in which case the function will be applied to the object having the property;:validator
a function of one argument returning a boolean, which will be applied to the value or values of the identified property.
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. Detailed verification of the particular features of types is not done here.
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, as a set of strings, or nil
(indicating the type of the referenced object should not be checked).
NOTE THAT if *reify-refs*
is false
, referenced objects will not actually be checked.
properties-faults
(properties-faults x)
Return a lost of faults found on properties of the object x
, or nil
if none are.