stixex v0.1.1 StixEx.Validation View Source

Some extra validations for checking some of the more esoteric requirements demanded by the spec

Link to this section Summary

Functions

Ensure that AT LEAST ONE of the fields is present in the changeset

Wrapper to generate our validation function. Essentially curries the validate function with a set vocabulary name so we don't have to do captures on every validation

Validate that a given value (or list of values) are members of a vocabulary

Link to this section Functions

Link to this function

validate_mutually_exclusive(changeset, field_a, field_b) View Source

Link to this function

validate_one_of(changeset, fields \\ []) View Source

Ensure that AT LEAST ONE of the fields is present in the changeset

iex> StixEx.Validation.validate_one_of(%{changes: %{my_field: 1}}, [:my_field])
%{changes: %{my_field: 1}, valid?: true}

iex> StixEx.Validation.validate_one_of(%{changes: %{}}, [:my_field])
%{changes: %{}, valid?: false}
Link to this function

validate_url(field, url) View Source

Link to this function

validate_values_in_enum(enum) View Source

Link to this function

validate_values_in_enum(enum, field, value) View Source

Link to this function

validate_values_in_vocab(vocabulary) View Source

Wrapper to generate our validation function. Essentially curries the validate function with a set vocabulary name so we don't have to do captures on every validation.

iex> validate_values_in_vocab("threat-actor-role-ov")
#Function<...>
Link to this function

validate_values_in_vocab(vocabulary, field, value) View Source

Validate that a given value (or list of values) are members of a vocabulary.

Will enforce key validity if :stixex, :enforce_vocabularies is set.