/
metadata.ex
47 lines (45 loc) · 1.02 KB
/
metadata.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
defmodule Ash.Resource.Actions.Metadata do
@moduledoc "Represents metadata from an action"
defstruct [
:allow_nil?,
:type,
:name,
:default,
:description,
constraints: []
]
@type t :: %__MODULE__{}
def schema do
[
allow_nil?: [
type: :boolean,
default: true,
doc: "Whether or not the metadata may return `nil`"
],
type: [
type: :any,
required: true,
doc: "The type of the metadata"
],
name: [
type: :atom,
required: true,
doc: "The name of the metadata"
],
default: [
type: :any,
doc:
"The default value for the metadata to take. It can be a zero argument function e.g `&MyMod.my_fun/0` or a value"
],
constraints: [
type: :keyword_list,
default: [],
doc: "Type constraints on the metadata"
],
description: [
type: :string,
doc: "An optional description for the metadata."
]
]
end
end