Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ash Custom Types Constraints Validations #1899

Open
djcarpe opened this issue Mar 22, 2025 · 0 comments
Open

Ash Custom Types Constraints Validations #1899

djcarpe opened this issue Mar 22, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@djcarpe
Copy link

djcarpe commented Mar 22, 2025

Describe the bug
There are no compiler errors to misconfiguring the constraints fields keyword lists.

To Reproduce
Create a new type with an incorrect type keyword list.

defmodule MyApp.FooType do
  alias MyApp.BarResource
  use Ash.Type.NewType,
    subtype_of: :map,
    constraints: [
      fields: [
        bars: [type: :struct, instance_of: BarResource]
      ]
    ]
end

The correct keyword list would be as such:

defmodule MyApp.FooType do
  alias MyApp.BarResource
  use Ash.Type.NewType,
    subtype_of: :map,
    constraints: [
      fields: [
        bars: [type: :struct, constraints: [ instance_of: BarResource]]
      ]
    ]
end

Expected behavior
An error at compile time for unknown keys or incorrect keys.

Runtime

  • Elixir version 1.18.1
  • Erlang version 27.2
  • OS macOS Sonoma 14.7
  • Ash version 3.4.71
  • any related extension versions
  • ash_json_api 1.4.22

Additional context

Link to discord thread: https://discord.com/channels/711271361523351632/1254774851428814930/1352834543408775228

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Someday
Development

No branches or pull requests

2 participants