Current section
Files
Jump to
Current section
Files
lib/ex_shopify_schema/graphql/int.ex
defmodule ExShopifySchema.Graphql.Int do
@moduledoc "Represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1."
@type t() :: integer()
use Ecto.Type
@impl Ecto.Type
def type, do: :integer
@impl Ecto.Type
def cast(nil), do: {:ok, nil}
def cast(int) when is_integer(int), do: {:ok, int}
def cast(_data), do: :error
@impl Ecto.Type
def load(data), do: cast(data)
@impl Ecto.Type
def dump(nil), do: {:ok, nil}
def dump(int) when is_integer(int), do: {:ok, int}
def dump(_data), do: :error
end