The validations in rails (activemodel/activerecord) have the ability to 
produce errors that can be internationalized through I18n.

I've been working on a gem called validation_hints, that provides hints on 
the attributes that have validations, that can be used as a tool tip or 
some other way of context sensitive help in forms.

https://rubygems.org/gems/validation_hints

For instance, if a Person model has a presence validation on the name 
attribute, Person.new.hints[:name] would be ["can't be blank"].
Person.new.hints, Person.new.hints.full_messages etc. have more or less the 
same behavior as #errors, except that errors is populated after validation 
but hints is populated by calling #hints (Person.new.hints will give you 
hints, where Person.new.errors won't give you anything because validation 
did not yet take place)

It's by no means complete, (it has no tests yet, any help appreciated), but 
it works for
- the standard ActiveModel validations, 
- most options (but not all)
- Custom Validators
- it can take :message => String or :message=> Symbol; the String will be 
reproduced literally, but the Symbol works with I18n.

Comments appreciated.





-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-core/-/gbh3sEXHdZkJ.
To post to this group, send email to rubyonrails-core@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-core+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Reply via email to