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

Add custom messages #243

Closed
wants to merge 1 commit into from
Closed

Conversation

kzielonka
Copy link

@kzielonka kzielonka commented Aug 29, 2016

In my current project validation shouldn't just return messages but objects with fields like :error_code (for example INVALID_EMAIL_ERROR and :message (which is an normal message like Email format is invalid.).
I didn't know how to do it using :yaml or :i18n messages providers so I created this pull request.

I extended Dry::Validation::Schema to accept custom messages object.
The setting option messages can now be one of :yaml, :i18n or :custom.
If :custom option is set custom_messages should also be set as Object which implements #default_locale and #[](key, options) methods.
Method #[](key, options) should return objects which implement #% (for example Strings but not necessary) or is a subclass of Dry::Validation::Messages::Abstract (please check tests for more details how it can be sued).

Plese check is it ok and I hope that it will be merged into master ;)

obj
end

before :each do
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just before ?

@solnic solnic force-pushed the master branch 2 times, most recently from 9997bdc to 513c6aa Compare December 3, 2016 17:35
@solnic
Copy link
Member

solnic commented Feb 13, 2019

This API was moved to dry-schema project. It's possible that its specialization will be re-added to dry-validation, for now this PR is outdated. We can get back to this when things are more settled in master, as the lib was rewritten on top of dry-schema.

@solnic solnic closed this Feb 13, 2019
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

Successfully merging this pull request may close these issues.

None yet

3 participants