# dog-and-duck.quack.picky.utils documentation

## Generated by Codox

# Dog-and-duck 0.1.0-SNAPSHOT

# dog-and-duck.quack.picky.utils

Utility functions supporting the picky validator

### actor-type?

`(actor-type? x)`

Return `true` if the `x` is a recognised actor type, else `false`.

view source

### any-or-faults

`(any-or-faults options severity-if-none token)`

Return `nil` if validating one of these options returns `nil`; otherwise return a list comprising a fault report object with this `severity-if-none` and this token followed by all the fault reports from validating each option.

There are several places - but especially in validating collections - where there are several different valid configurations, but few or no properties are always required.

view source

### 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.

view source

### concat-non-empty

`(concat-non-empty & lists)`

Quick function to replace the pattern (nil-if-empty (remove nil? (concat …))) which I’m using a lot!

view source

### cond-make-fault-object

#### macro

`(cond-make-fault-object v severity token)`

If `v` is `false` or `nil`, return a fault object with this `severity` and `token`, else return nil.

view source

### context?

`(context? x)`

Returns `true` iff `x` quacks like an ActivityStreams context, else false.

A context is either 1. the URI (actually an IRI) `activitystreams-context-uri`, or 2. a collection comprising that URI and a map.

view source

### filter-severity

`(filter-severity reports severity)`

Return a list of reports taken from these `reports` where the severity of the report is greater than this or equal to this `severity`.

view source

### has-activity-type?

`(has-activity-type? x)`

Return `true` if the object `x` has a type which is an activity type, else `false`.

view source

### has-actor-type?

`(has-actor-type? x)`

Return `true` if the object `x` has a type which is an actor type, else `false`.

view source

### has-context?

#### macro

`(has-context? x)`

True if `x` is an ActivityStreams object with a valid context, else `false`.

view source

### has-type-or-fault

`(has-type-or-fault x acceptable severity token)`

If object `x` has a `:type` value which is `acceptable`, return `nil`; else return a fault object with this `severity` and `token`.

`acceptable` may be passed as either nil, a string, or a set of strings. If `acceptable` is `nil`, no type specific tests will be performed.

view source

### has-type?

`(has-type? x type)`

Return `true` if object `x` has type `type`, else `false`.

The values of `type` fields of ActivityStreams objects may be lists; they are considered to have a type if the type token is a member of the list.

view source

### link-or-uri?

#### macro

`(link-or-uri? x)`

Very basic check that `x` is either a link object or a URI.

view source

### make-fault-object

`(make-fault-object severity fault)`

Return a fault object with these `severity`, `fault` and `narrative` values.

An ActivityPub object MUST have a globally unique ID. Whether this is meaningful depends on whether we persist fault report objects and serve them, which at present I have no plans to do.

view source

### nil-if-empty

#### macro

`(nil-if-empty x)`

if `x` is an empty collection, return `nil`; else return `x`.

view source

### 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.

view source

### object-or-uri?

`(object-or-uri? x)`

Very basic check that `x` is either an object or a URI.

view source

### object-reference-or-faults

`(object-reference-or-faults value expected-type severity token)`

If this `value` is either

1. an object of `expected-type`;
2. a URI referencing an object of `expected-type`; or
3. 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.

view source

### 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`.

view source

### truthy?

`(truthy? x)`

Return `true` if `x` is truthy, else `false`. There must be some more idiomatic way to do this?

view source

### verb-type?

`(verb-type? x)`

`true` if `x`, a string, represents a recognised ActivityStreams activity type.

view source