You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.
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):
it"should have correct error messages"docustom_boat=Class.newdoincludeDataMapper::Resourcedefself.name'Boat'endproperty:id,DataMapper::Property::Serialproperty:length,Integer,:min=>1,:messages=>{:greater_than_or_equal_to=>"Length must be at least 1"}endboat=custom_boat.newboat.length=0boat.should_notbe_validboat.errors.on(:length).should == ['Length must be at least 1']boat.length=3boat.shouldbe_validboat.errors.on(:length).shouldbe_nil
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:
'Inferred validations should have correct error messages' FAILED
expected: ["Length must be at least 1"],
got: [#<DataMapper::Validation::Violation @resource=#<Boat @id=nil @name="superboat" @length=0> @rule=#<Dat
aMapper::Validation::Rule::Numericalness::GreaterThanOrEqual @attribute_name=:length @allow_nil=true @allow_blan
k=nil @custom_message=nil @if_clause=nil @unless_clause=nil @expected=1> @custom_message=nil @attribute_name=:le
ngth>] (using ==)
Is there a good reason why boat.errors does not get a string attached due to the failed validation but this Violation instance instead? Does it make sense to change that?
I would love to provide a pull request if you think this change makes sense.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: