improvement: Add Changeset.is_valid/1 guard. (#1437)

This commit is contained in:
James Harton 2024-09-06 12:57:36 +12:00 committed by GitHub
parent b6e1e80fc2
commit 295778bbf5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -362,6 +362,12 @@ defmodule Ash.Changeset do
end
end
@doc """
A guard which checks if the Changeset is valid.
"""
@spec is_valid(t) :: Macro.output()
defguard is_valid(changeset) when is_struct(changeset, __MODULE__) and changeset.valid? == true
@doc """
Returns a new changeset over a resource.