RegexpError when using auto-validated Float properties
Reported by Alex Coles | May 22nd, 2008 @ 06:43 AM
Currently encountering a problem with the numeric validator, when being applied (with autovalidations on numerics) on two separate models for two separate projects.
Models are here:
When valid? is called in specs, I am getting the following:
RegexpError in 'Version.new should require content'
can't do {n,m} with n > m: /\A(?:\d{1,10}|\d{0,10}\.\d{1,0})\z/
/Library/Ruby/Gems/1.8/gems/dm-validations-0.9.0/lib/dm-validations/numeric_validator.rb:31:in `call'
/Library/Ruby/Gems/1.8/gems/dm-validations-0.9.0/lib/dm-validations/contextual_validators.rb:47:in `execute'
/Library/Ruby/Gems/1.8/gems/dm-validations-0.9.0/lib/dm-validations/contextual_validators.rb:45:in `each'
/Library/Ruby/Gems/1.8/gems/dm-validations-0.9.0/lib/dm-validations/contextual_validators.rb:45:in `execute'
/Library/Ruby/Gems/1.8/gems/dm-validations-0.9.0/lib/dm-validations.rb:54:in `valid?'
./spec/models/version_spec.rb:44:
Will investigate further to reduce this down...
Comments and changes to this ticket
-
Alex Coles May 22nd, 2008 @ 06:44 AM
(I can't currently assign myself to this -- but I will try to investigate. Bug is in here to track)
-
Alex Coles May 22nd, 2008 @ 07:13 AM
- → Title changed from Numeric Validator throwing a RegexpError to RegexpError when using auto-validated Float properties
Reduced this down to a problem with Floats and auto-validations.
This works:
class Fish include DataMapper::Resource property :id, Integer, :serial => true property :scales, Integer property :average_weight, Float, :auto_validation => false validates_is_number :average_weight end fish = Fish.new fish.scales = 1 fish.average_weight = 20.22 fish.valid?.should == true # => trueand this does not:
class Fish include DataMapper::Resource property :id, Integer, :serial => true property :scales, Integer property :average_weight, Float end fish = Fish.new fish.scales = 1 fish.average_weight = 20.22 fish.valid?.should == true # RegexpError =>can't do {n,m} with n > m: /\A(?:\d{1,10}|\d{0,10}\.\d{1,0})\z/ -
Alex Coles May 22nd, 2008 @ 07:34 AM
Should be fixed in commit c88cc4e
(As an aside, all of the validations need better specs).
-
Dan Kubb May 25th, 2008 @ 07:40 PM
- → State changed from new to resolved
Verified this ticket is fixed and beefed up the specs to handle extra conditions: http://github.com/sam/dm-more/co...
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 »
