From ac72c623d903a46d008aab9f5b257660ed3cbc9c Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Sun, 21 Mar 2021 11:31:25 -0400 Subject: [PATCH] fix: allow casting strings as uuids (for embedded types) --- lib/ash/type/uuid.ex | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ash/type/uuid.ex b/lib/ash/type/uuid.ex index 7ec857f1..00384aa7 100644 --- a/lib/ash/type/uuid.ex +++ b/lib/ash/type/uuid.ex @@ -20,8 +20,11 @@ defmodule Ash.Type.UUID do end @impl true - def cast_stored(value, _) do + def cast_stored(value, constraints) do Ecto.Type.load(Ecto.UUID, value) + rescue + _e in ArgumentError -> + cast_input(value, constraints) end @impl true