-
Notifications
You must be signed in to change notification settings - Fork 3
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
Enable or document shared formats #10
Comments
We plan to support this is with custom attribute types, which is a feature in the backlog. I've documented it in this repo as issue #11. A workaround to do what you wrote is to use Code.require_file in your spec: Code.require_file "../lib/format.ex"
struct Example.Message
attribute :uuid, :string, format: Format.uuid defmodule Format do
def uuid do
~r/\A\d{5}\-\d{5}\-\d{5}\-\d{5}\-\d{4}\z/
end
end Please continue this thread if you run into any other issues with this approach. |
Functionality will be covered by #11 |
|
Another workaround is to make the |
The docs show using formats like this:
When multiple schemas use a uuid of that format, it would be less error-prone to be able to do something like:
I don't see anything like this in the docs. Is it supported? If not, could it be?
So far I've attempted to use a separate module and ensure that it's compiled before the schema using
require
,@before_compile
, andelixirc_paths
, but I always get an error saying that the module is unavailable. Maybe this is because the Speck compiler runs before any of theMix.compilers
?The text was updated successfully, but these errors were encountered: