# `PhoenixMicro.Schema.Field`
[🔗](https://github.com/iamkanishka/phoenix_micro/blob/v1.0.0/lib/phoenix_micro/schema/field.ex#L1)

Represents a single field definition in a `PhoenixMicro.Schema`.

Fields are defined via the `field/2` and `field/3` macros:

    field :payment_id,   :string,  required: true
    field :amount_cents, :integer, required: true
    field :currency,     :string,  required: true, default: "USD"
    field :metadata,     :map,     required: false

## Supported types

| Type       | Elixir check              |
|------------|---------------------------|
| `:string`  | `is_binary/1`             |
| `:integer` | `is_integer/1`            |
| `:float`   | `is_float/1` or integer   |
| `:boolean` | `is_boolean/1`            |
| `:map`     | `is_map/1`                |
| `:list`    | `is_list/1`               |
| `:atom`    | `is_atom/1` or binary     |
| `:any`     | always passes             |

# `field_type`

```elixir
@type field_type() ::
  :string | :integer | :float | :boolean | :map | :list | :atom | :any
```

# `t`

```elixir
@type t() :: %PhoenixMicro.Schema.Field{
  default: term(),
  description: String.t() | nil,
  name: atom(),
  required: boolean(),
  type: field_type()
}
```

# `new`

```elixir
@spec new(atom(), field_type(), keyword()) :: t()
```

Builds a `Field` struct from the DSL arguments.

# `valid_type?`

```elixir
@spec valid_type?(term(), field_type()) :: boolean()
```

Returns true if the value matches the given type.

# `validate_value`

```elixir
@spec validate_value(t(), term()) :: :ok | {:error, String.t()}
```

Validates a single value against this field's type.
Returns `:ok` or `{:error, message}`.

---

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