Changeset [cd100fee5ce98e8ade231b8aa4386c70817d3ccc] by Markus Schirp

November 27th, 2011 @ 06:17 PM

Fix inconsistency in Rule::PrimitiveType

There was a discussion between me an solnic month ago. I thought we
have to test the loaded value against load_as. Solnic convinced me we
have to test against the dump_as.

But something totally different was implemented: Testing loaded value
(property.get resource), against dumped value. This was not spotted since 99% of all datamapper properties have load_as == dump_as.

References:

http://irclogger.com/.datamapper/2011-10-21 (search for value_loaded?) https://github.com/mbj/dm-validations/commit/75c59049d6f51b5a0038ef...

@solnic, @emmanuel This time I am 99.9999% sure my thoughts are correct. I would also accept testing dumped_value against dump_as. But the purpose of
the primitive type rule is to catch cases the typecast was not able to
coerce a property value.
https://github.com/datamapper/dm-validations/commit/cd100fee5ce98e8...

Committed by Markus Schirp

  • A spec/fixtures/integer_dumped_as_string_property.rb
  • M lib/data_mapper/validation/rule/primitive_type.rb
  • M spec/fixtures/memory_object.rb
  • M spec/integration/primitive_validator/primitive_validator_spec.rb
New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »