Deprecate option type helper (#352)

This commit is contained in:
zimt28 2022-07-18 21:22:17 +02:00 committed by GitHub
parent e83fcf13fb
commit bc05fb5b47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View file

@ -143,6 +143,7 @@ defmodule Ash.OptionsHelpers do
def map(value) when is_map(value), do: {:ok, value} def map(value) when is_map(value), do: {:ok, value}
def map(_), do: {:error, "must be a map"} def map(_), do: {:error, "must be a map"}
@deprecated "Use {:list, :atom} instead"
def list_of_atoms(value) do def list_of_atoms(value) do
if is_list(value) and Enum.all?(value, &is_atom/1) do if is_list(value) and Enum.all?(value, &is_atom/1) do
{:ok, value} {:ok, value}

View file

@ -38,11 +38,11 @@ defmodule Ash.Resource.Actions.SharedOptions do
@create_update_opts [ @create_update_opts [
accept: [ accept: [
type: {:custom, Ash.OptionsHelpers, :list_of_atoms, []}, type: {:list, :atom},
doc: "The list of attributes to accept. Defaults to all attributes on the resource" doc: "The list of attributes to accept. Defaults to all attributes on the resource"
], ],
reject: [ reject: [
type: {:custom, Ash.OptionsHelpers, :list_of_atoms, []}, type: {:list, :atom},
doc: """ doc: """
A list of attributes not to accept. This is useful if you want to say 'accept all but x' A list of attributes not to accept. This is useful if you want to say 'accept all but x'
@ -51,7 +51,7 @@ defmodule Ash.Resource.Actions.SharedOptions do
""" """
], ],
require_attributes: [ require_attributes: [
type: {:custom, Ash.OptionsHelpers, :list_of_atoms, []}, type: {:list, :atom},
doc: """ doc: """
A list of attributes that would normally `allow_nil` to require for this action. A list of attributes that would normally `allow_nil` to require for this action.