View Source Estructura.Full (estructura v1.4.0)

Full Example

Summary

Functions

Returns the generator to be used in StreamData-powered property testing, based on the specification given to use Estructura, which contained

Gets the value for the given key from the structure

Puts the value for the given key into the structure, passing coercion and validation, returns {:ok, updated_struct} or {:error, reason} if there is no such key

Puts the value for the given key into the structure, passing coercion and validation, returns the value or raises if there is no such key

Functions

@spec __generator__() ::
  StreamData.t(%Estructura.Full{
    bar: term(),
    baz: term(),
    foo: term(),
    zzz: term()
  })

See Estructura.Full.__generator__/1

@spec __generator__(%Estructura.Full{
  bar: term(),
  baz: term(),
  foo: term(),
  zzz: term()
}) ::
  StreamData.t(%Estructura.Full{
    bar: term(),
    baz: term(),
    foo: term(),
    zzz: term()
  })

Returns the generator to be used in StreamData-powered property testing, based on the specification given to use Estructura, which contained

shape

%Estructura.Config{
  access: true,
  coercion: [:foo],
  validation: true,
  calculated: [],
  collectable: :bar,
  enumerable: true,
  generator: [
    foo: {StreamData, :integer, [0..1000]},
    bar: {StreamData, :string, [:alphanumeric]},
    baz: {StreamData, :fixed_map,
     [[key1: {StreamData, :integer}, key2: {StreamData, :integer}]]},
    zzz: &Estructura.Full.zzz_generator/0
  ]
}

The argument given would be used as a template to generate new values.

Link to this function

get(data, key, default \\ nil)

View Source
@spec get(
  %Estructura.Full{bar: term(), baz: term(), foo: term(), zzz: term()},
  Estructura.Config.key(),
  any()
) :: any()

Gets the value for the given key from the structure

@spec put(
  %Estructura.Full{bar: term(), baz: term(), foo: term(), zzz: term()},
  Estructura.Config.key(),
  any()
) ::
  {:ok, %Estructura.Full{bar: term(), baz: term(), foo: term(), zzz: term()}}
  | {:error, any()}

Puts the value for the given key into the structure, passing coercion and validation, returns {:ok, updated_struct} or {:error, reason} if there is no such key

@spec put!(
  %Estructura.Full{bar: term(), baz: term(), foo: term(), zzz: term()},
  Estructura.Config.key(),
  any()
) ::
  %Estructura.Full{bar: term(), baz: term(), foo: term(), zzz: term()}
  | no_return()

Puts the value for the given key into the structure, passing coercion and validation, returns the value or raises if there is no such key

Link to this function

recalculate_calculated(data)

View Source