stixex v0.1.1 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
Link to this function
get(name) View Source
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"}}
Link to this function
get!(name) View Source
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
Link to this callback
values()
View Source
values()
View Source
values() :: [String.t()]
values() :: [String.t()]