Current section

Files

Jump to
diffo lib diffo provider assigner assignable_value.ex
Raw

lib/diffo/provider/assigner/assignable_value.ex

# SPDX-FileCopyrightText: 2025 diffo contributors <https://github.com/diffo-dev/diffo/graphs.contributors>
#
# SPDX-License-Identifier: MIT
defmodule Diffo.Provider.AssignableValue do
@moduledoc """
Ash Typed Struct for Assignable Characteristic Value
"""
use Ash.TypedStruct, extensions: [AshJason.TypedStruct]
jason do
pick [:first, :last, :free, :assignable_type, :algorithm]
compact true
rename assignable_type: :type
end
typed_struct do
field :first, :integer,
description: "the first assignable thing",
default: 1,
constraints: [min: 0]
field :last, :integer,
description: "the last assignable thing",
default: 1,
constraints: [min: 0]
field :free, :integer,
description: "the number of free things",
default: 1,
constraints: [min: 0]
field :assignable_type, :string, description: "the type of the assignable thing"
field :algorithm, :atom,
description: "the assignment algorithm",
default: :lowest,
constraints: [one_of: [:lowest, :highest, :random]]
end
defimpl String.Chars do
def to_string(struct) do
inspect(struct)
end
end
end