Commits

Mahlon Smith committed 1d71e22

Revalidate parameters when using the index operator.

Comments (0)

Files changed (2)

lib/strelka/paramvalidator.rb

 	### Index fetch operator; fetch the validated (and possible parsed) value for
 	### form field +key+.
 	def []( key )
+		self.validate unless self.validated?
 		return @valid[ key.to_sym ]
 	end
 

spec/strelka/paramvalidator_spec.rb

 			@validator.param_names.should include( 'a_field' )
 		end
 
+		it "revalidates parameters when new constraints are added" do
+			@validator.validate( 'blorp' => 'true' )
+			@validator[ :blorp ].should be_nil
+			@validator.add( :blorp, :boolean )
+			@validator[ :blorp ].should be_true
+		end
+
 		it "ignores identical duplicate constraints to be added twice" do
 			@validator.add( :a_field, :string )
 			@validator.add( :a_field, :string )