# `BB.Message.Option`
[🔗](https://github.com/beam-bots/bb/blob/main/lib/bb/message/option.ex#L5)

Custom Spark.Options types for message primitives.

Provides type functions for use in payload schemas to validate
`BB.Math.Vec3.t()`, `BB.Math.Quaternion.t()`, and `BB.Math.Transform.t()` types.

## Usage

    import BB.Message.Option

    @schema Spark.Options.new!([
      position: [type: vec3_type(), required: true],
      orientation: [type: quaternion_type(), required: true],
      pose: [type: transform_type(), required: true]
    ])

# `quaternion_type`

```elixir
@spec quaternion_type() :: {:custom, module(), atom(), list()}
```

Returns a Spark.Options type for validating `BB.Quaternion.t()`.

## Examples

    iex> BB.Message.Option.quaternion_type()
    {:custom, BB.Message.Option, :validate_quaternion, [[]]}

# `transform_type`

```elixir
@spec transform_type() :: {:custom, module(), atom(), list()}
```

Returns a Spark.Options type for validating `BB.Math.Transform.t()`.

## Examples

    iex> BB.Message.Option.transform_type()
    {:custom, BB.Message.Option, :validate_transform, [[]]}

# `validate_quaternion`

```elixir
@spec validate_quaternion(
  term(),
  keyword()
) :: {:ok, BB.Math.Quaternion.t()} | {:error, String.t()}
```

Validates a BB.Quaternion struct.

## Examples

    iex> BB.Message.Option.validate_quaternion(BB.Quaternion.identity(), [])
    {:ok, %BB.Quaternion{}}

    iex> BB.Message.Option.validate_quaternion("not a quaternion", [])
    {:error, "expected BB.Quaternion.t(), got: \"not a quaternion\""}

# `validate_transform`

```elixir
@spec validate_transform(
  term(),
  keyword()
) :: {:ok, BB.Math.Transform.t()} | {:error, String.t()}
```

Validates a BB.Math.Transform struct.

## Examples

    iex> BB.Message.Option.validate_transform(BB.Math.Transform.identity(), [])
    {:ok, %BB.Math.Transform{}}

    iex> BB.Message.Option.validate_transform("not a transform", [])
    {:error, "expected BB.Math.Transform.t(), got: \"not a transform\""}

# `validate_vec3`

```elixir
@spec validate_vec3(
  term(),
  keyword()
) :: {:ok, BB.Math.Vec3.t()} | {:error, String.t()}
```

Validates a BB.Vec3 struct.

## Examples

    iex> BB.Message.Option.validate_vec3(BB.Vec3.new(1.0, 2.0, 3.0), [])
    {:ok, %BB.Vec3{}}

    iex> BB.Message.Option.validate_vec3("not a vec3", [])
    {:error, "expected BB.Vec3.t(), got: \"not a vec3\""}

# `vec3_type`

```elixir
@spec vec3_type() :: {:custom, module(), atom(), list()}
```

Returns a Spark.Options type for validating `BB.Vec3.t()`.

## Examples

    iex> BB.Message.Option.vec3_type()
    {:custom, BB.Message.Option, :validate_vec3, [[]]}

---

*Consult [api-reference.md](api-reference.md) for complete listing*
