Enforce each item is unique in attribute array

Hi, is there a way to set a constraint on this array attribute, that enforces each item to be unique? For example it should not allow [:en, :en] .
attribute :languages, {:array, :atom} do
default [:en]
constraints [
min_length: 1,
items: [
one_of: [:en, :de, :fr],
]
]
end
attribute :languages, {:array, :atom} do
default [:en]
constraints [
min_length: 1,
items: [
one_of: [:en, :de, :fr],
]
]
end
Thanks in advance!
2 Replies
ZachDaniel
ZachDaniel3mo ago
Not as an array, no You can make a custom type, or add a validation to the action/resource etc.
cr0nk
cr0nkOP3mo ago
Okay thanks!

Did you find this page helpful?