:message option for property declaration
Reported by ronin-26610 (at lighthouseapp) | July 19th, 2008 @ 04:45 PM
When using auto validation it`s impossible to specify custom error message. It would allow code like this:
property :title, String, :nullable => false, :message => "Please provide title"
All needed is:
module DataMapper
class Property
PROPERTY_OPTIONS << :message
end
end
and then in DataMapper::Validate::AutoValidate#auto_generate_validations
add line:
opts[:message] = property.options[:message] if property.options.has_key?(:message)
it`s undestructive but very helpful
Comments and changes to this ticket
-

ronin-26610 (at lighthouseapp) July 19th, 2008 @ 08:20 PM
Usage:
property :title, String, :nullable => false, :length => (4..20), :messages => {:presence => "Title can`t be blank", :length => "Title should be between 4 and 21 chars"}
or if there is only one condition:
property :title, String, :nullable => false, :message => "Title cant`t be blank"
Patch included
-
Sam Smoot July 20th, 2008 @ 02:18 PM
- → Assigned user changed from Sam Smoot to Adam French
Adam, please apply.
-
Adam French July 20th, 2008 @ 04:15 PM
- → State changed from new to open
@teamon I'll apply the patch, but please include specs with your patches next go round :-) KTHXBYE
-

-
Adam French July 20th, 2008 @ 05:43 PM
- → State changed from open to resolved
patch with spec has been applied. Thanks teamon!
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
