mbj / aequitas

A PORO Validations library. Now.
MIT License
20 stars 2 forks source link

Support generation of human readable error messages #6

Open yeban opened 11 years ago

yeban commented 11 years ago

I had a cursory look at the code. Looks like aequitas doesn't allow setting message on validation rules and being able to use the same as violations.to_s (maybe). Is it planned?

mbj commented 11 years ago

@yeban This library does not support the generation of "human readable validation error messages", intentionally. And yeah, it is planned. But not with violation.to_s. I'd rather prefer a set of "decorating" classes, such as:

Message.generate(violation, :de) #=> "Feld XYZ ist nicht ausgefüllt".

This way it is far easier to support i18n, and very custom violations. I'll keep this issue open till a solution is in tree.

yeban commented 11 years ago

Thanks for the quick response, @mbj. Do you have any plans regarding when could one expect a solution to be in?

mbj commented 11 years ago

@yeban I don't plan to add this feature soon. Just be cause my time for opensource is very limited currently, and I have more important stuff in my queue. I'm very happy to guide you through this process, in case you are about to contribute?

yeban commented 11 years ago

I could try, but only after mid-July. Before that I am quite swamped too. Besides, this is not urgent for me yet. I will ping you when I get time and if nothing is in tree by then. Thanks.

On a slightly related note: this feature would be important if aequitas is to be used as a DM2 component, right?

mbj commented 11 years ago

dm2 will focus on this: Being a good mapper. We not plan to couple the mapper with a validations library, also I do not plan to couple this library to dm2. You see some use of general support gems here, but it is perfectly usable outside the dm2 ecosystem. It'll just pull some support gems if you use it.

Also as a side note, I like the idea behind SRP. So this library does NOT infect your model with additional logic, it only provides an external validator. So you literally cannot couple it to a domain object / mapper ;)

BTW free to catch me in #datamapper (freenode).