PropSchema v1.0.0 PropSchema.AdditionalProperties behaviour
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)
(optional)
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)
(optional)
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