I just overrode DM::V::ValidationErrors.default_error_messages
somewhere after the gem is loaded, but before models are. In Rails 3,
this means creating an initializer and placing http://gist.github.com/447681
in it. Total monkey patch, but it works.
As for custom validation, you'd most likely want to create a validator
class that inherits from DM::V::GenericValidator. The catch with:
> if u.valid?
> u.errors.add(:name, 'Invalid name')
> puts "Valid: #{u.valid?}"
> end
is that calling #valid? actually clears all errors, then reruns all
validators for that resource.
However, if you only want to override the default validation error
messages, might I suggest another ugly hack: http://gist.github.com/447683
.
-rp
> --
> You received this message because you are subscribed to the Google
> Groups "DataMapper" group.
> To post to this group, send email to datam...@googlegroups.com.
> To unsubscribe from this group, send email to datamapper+...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/datamapper?hl=en
> .
>