Skip to content

Commit

Permalink
improvement: Don't just all the values when there may be a large numb…
Browse files Browse the repository at this point in the history
…er of values. (#106)
  • Loading branch information
jimsynz authored Sep 1, 2024
1 parent bddcd06 commit b20a5ab
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/spark/options/options.ex
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,22 @@ defmodule Spark.Options do

defp document_values(opts) do
case opts[:type] do
{in_type, range}
when in_type in [:in, :one_of] and is_struct(range, Range) and range.step > 0 ->
Keyword.update!(
opts,
:doc,
&"#{&1} Valid values are between #{range.first} and #{range.last}"
)

{in_type, range}
when in_type in [:in, :one_of] and is_struct(range, Range) and range.step < 0 ->
Keyword.update!(
opts,
:doc,
&"#{&1} Valid values are between #{range.last} and #{range.first}"
)

{in_type, values} when in_type in [:in, :one_of] ->
values = Enum.map_join(values, ", ", &inspect/1)

Expand Down

0 comments on commit b20a5ab

Please sign in to comment.