The handlers of the :safe option and the codes they are called with.
See the section on safe mode in JSON.LD.Options for what the option checks.
With a function as the value of the option, processing does not fail where data is
dropped: the function is called with a code for what is dropped and with a map of
details, and when it returns, processing goes on as without the option. What it raises
ends processing. fail/2 is the handler of safe: true, so that a handler can delegate
to it what it does not handle itself:
JSON.LD.to_rdf(document,
safe: fn
:blank_node_predicate, _details -> :ok
code, details -> JSON.LD.SafeMode.fail(code, details)
end
)What a handler lets pass is not part of the RDF, and a signature over the RDF does not cover it. The same data can be reported twice: a reference to a node whose identifier is not a valid IRI is reported as a value and as a node.
Codes
The codes and the keys of their details:
| Code | Dropped | Details |
|---|---|---|
:invalid_property | a property that does not expand to an IRI or a keyword | :property, :expanded_property |
:free_floating_scalar | a free-floating scalar | :value |
:free_floating_value | a free-floating value object | :value |
:free_floating_list | a free-floating list | :value |
:free_floating_node | a free-floating node object with nothing but an @id | :value |
:null_value | a value object without a value but with other entries | :value |
:object_with_only_language | an object with nothing but @language | :value |
:map_key_without_value | a key of a language, index, id or type map that has no value | :key, :property |
:unprocessed_keyword | the value of a keyword that is not processed in a node object | :keyword, :value |
:relative_graph_reference | a graph name that is not a valid IRI | :graph |
:relative_subject_reference | a node identifier that is not a valid IRI | :subject |
:relative_type_reference | the types of a node that are not valid IRIs | :subject, :types |
:relative_predicate_reference | a property that is not a valid IRI | :property |
:blank_node_predicate | a blank node as property | :property, the identifier as in the expanded input; :path, the keys and array indexes from the top of the input to the key that is dropped |
:relative_object_reference | a node reference that is not a valid IRI | :value, outside of a list also :subject and :property |
:invalid_language_value | a value with a language tag that is not well-formed | :value, outside of a list also :subject and :property |
:rdf_direction_not_set | a base direction, when :rdf_direction is not set | :value |
:node_without_statement | a node identifier that is not part of any statement | :subject |
A blank node as :subject has the identifier of the node map, not the one of the
document.
Summary
Functions
Fails with the JSON.LD.Error of safe mode for the data that is dropped.
Types
@type code() ::
:free_floating_scalar
| :free_floating_value
| :free_floating_list
| :free_floating_node
| :invalid_property
| :unprocessed_keyword
| :map_key_without_value
| :null_value
| :object_with_only_language
| :relative_graph_reference
| :relative_subject_reference
| :relative_type_reference
| :blank_node_predicate
| :relative_predicate_reference
| :relative_object_reference
| :invalid_language_value
| :rdf_direction_not_set
| :node_without_statement
Functions
Fails with the JSON.LD.Error of safe mode for the data that is dropped.
This is the handler of safe: true. A handler of its own delegates to it what it does
not handle itself.
Examples
iex> JSON.LD.SafeMode.fail(:free_floating_scalar, %{value: 1})
** (JSON.LD.Error) safe mode: Free-floating scalar 1 is dropped