stixex v0.1.2 StixEx.Vocabulary behaviour View Source

Set vocabularies to restrict the values of certain fields to one of a given list

See specification section 6

Link to this section Summary

Functions

Get a vocabulary module based on its my-vocab-ov name

Get a vocabulary, throwing an error if it doesn't exist

Is a given value valid for a vocabulary?

Link to this section Functions

Get a vocabulary module based on its my-vocab-ov name

iex> StixEx.Vocabulary.get("hash-algorithm-ov")
{:ok, StixEx.Vocabulary.HashAlgorithm}

iex> StixEx.Vocabulary.get("my-silly-vocab-ov")
{:error, {:does_not_exist, "my-silly-vocab-ov"}}

iex> StixEx.Vocabulary.get("not-formatted")
{:error, {:invalid_name, "not-formatted"}}

Get a vocabulary, throwing an error if it doesn't exist

Link to this function

has_value?(vocabulary, value) View Source

Is a given value valid for a vocabulary?

iex> StixEx.Vocabulary.has_value?(StixEx.Vocabulary.HashAlgorithm, "MD5")
true

iex> StixEx.Vocabulary.has_value?("hash-algorithm-ov", "MD5")
true

iex> StixEx.Vocabulary.has_value?("hash-algorithm-ov", "notahash")
false

Link to this section Callbacks