PropSchema.AdditionalProperties behaviour (PropSchema v1.1.0) View Source

A behaviour that is used to define additional properties not provided in the base properties module.

How to Implement

Once you have implemented the callbacks below (see generate_prop/3 below), add the module that implements this behaviour as the option additional_properties in the PropSchema.TestHarness.__using__/1 declaration.

Link to this section Summary

Callbacks

Implement to define miscellaneous properties.

Implement to define additional properties not provided in the PropSchema.BaseProperties module.

Link to this section Callbacks

Link to this callback

generate_misc(excluded)

View Source (optional)

Specs

generate_misc(excluded :: atom()) :: [{String.t(), StreamData.t()}]

Implement to define miscellaneous properties.

Example

def generate_misc(:test_int) do
  quote do
    {"decoy_int", integer()}
  end
end
Link to this callback

generate_prop(atom, atom, map)

View Source (optional)

Specs

generate_prop(atom(), atom(), map()) :: [{String.t(), StreamData.t()}]

Implement to define additional properties not provided in the PropSchema.BaseProperties module.

Example

def generate_prop(field, :float, %{positive: true, required: true}) do
  quote do
    {unquote(Atom.to_string(field)), float(min: 1)}
  end
end