Describe the bug
using regex validate match(:pin, ~r/^[0-9]{4}$/) can't be directly sent to meta -> match because it's not possible to encode in JSON, in my case protocol Jason.Encoder not implemented for ~r/^[0-9]{4}$/ of type Regex (a struct), Jason.Encoder protocol must always be explicitly implemented.
To Reproduce
A minimal set of resource definitions and calls that can reproduce the bug.
defmodule Foo do
use Ash.Resource,
domain: Domain.Foo,
extensions: [AshJsonApi.Resource]
# to skip the error
# require Protocol
# Protocol.derive(Jason.Encoder, Regex, only: [])
json_api do
type "foo"
end
create :new_request do
primary? true
accept [:pin]
end
attributes do
attribute :pin, :string
end
validations do
validate match(:pin, ~r/^[0-9]{4}$/)
end
end
request HTTP with the wrong pin.
Expected behavior
A successful response with an error is defined.
Describe the bug using regex
validate match(:pin, ~r/^[0-9]{4}$/)
can't be directly sent tometa -> match
because it's not possible to encode in JSON, in my caseprotocol Jason.Encoder not implemented for ~r/^[0-9]{4}$/ of type Regex (a struct), Jason.Encoder protocol must always be explicitly implemented.
To Reproduce A minimal set of resource definitions and calls that can reproduce the bug.
Expected behavior A successful response with an error is defined.
** Runtime
Additional context
Errors while debugging