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

[Suggestion] Support for validation messaging #76

Open
kieraneglin opened this issue May 7, 2020 · 2 comments
Open

[Suggestion] Support for validation messaging #76

kieraneglin opened this issue May 7, 2020 · 2 comments

Comments

@kieraneglin
Copy link

Norm is proving to be very useful for validating schemas of internal processes. With that success, we're looking to use Norm as our primary validation within Ecto due to its robustness as well as an interest in keeping our approach to validation unified.

That said, the biggest thing that's holding us back is the error messages returned. Our approach to adding Norm errors to a changeset is simple (#7 (comment)), but results in errors like Title failed schema validation: &(String.length(&1) > 2) which is something we can't show to our end users.

I'd be open to taking a stab at allowing per-spec error messaging, but I worry that this would be outside of Norm's scope as it currently stands. Would there be any interest in a PR for this? If so, are there any suggestions for a preferred syntax?

@keathley
Copy link
Member

I've been thinking for a while about the best way to support customizable error messages. So far I haven't come up with anything that I really love. I was considering using a behaviour for this, but it would mean that you would need a way to set it either globally (probably through application env) or per spec or per conform call. Or perhaps some combination of all 3.

If you'd like to submit a PR I'd be happy to take a look at what you come up with. At the very least it would provide a basis for discussion.

@kieraneglin
Copy link
Author

@keathley Thanks for the input! I've thrown together a PR here with an initial attempt: #83

Hopefully that can be a jumping off point for conversation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants