Open nblumoe opened 11 years ago
+1
The DataMapper::Validation::Violation#to_s
method returns your expected result. If you replace
boat.errors.on(:length).should == [ 'Length must be at least 1' ]
with
boat.errors.on(:length).map(&:to_s).should == [ 'Length must be at least 1' ]
your example should work.
I would like to use custom error messages for all inferred validations. What I want to do is shown in this spec (based on this):
As you can see I would like to override the default error message for the auto validation derived from
:min => 1
. Currently this spec fails:Is there a good reason why
boat.errors
does not get a string attached due to the failed validation but thisViolation
instance instead? Does it make sense to change that?I would love to provide a pull request if you think this change makes sense.