Changeset 461

Show
Ignore:
Timestamp:
08/27/08 17:24:56 (3 months ago)
Author:
deveiant
Message:
  • Added some more javascript stuff to the manual resources dir
  • Made boolean constraints accept '1' or '0' in Arrow::FormValidator?
Location:
trunk
Files:
4 added
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/lib/arrow/formvalidator.rb

    r453 r461  
    306306    def match_boolean( val ) 
    307307        rval = nil 
    308         if ( val =~ /^(t(?:rue)?|y(?:es)?)$/i ) 
     308        if ( val =~ /^(t(?:rue)?|y(?:es)?)|1$/i ) 
    309309            rval = true 
    310         elsif ( val =~ /^(no?|f(?:alse)?)$/i ) 
     310        elsif ( val =~ /^(no?|f(?:alse)?)|0$/i ) 
    311311            rval = false 
    312312        end 
  • trunk/spec/arrow/formvalidator_spec.rb

    r453 r461  
    346346    end 
    347347     
     348    it "accepts the value '1' for fields with boolean constraints" do 
     349        params = {'required' => '1', 'bool_constraint' => '1'} 
     350     
     351        @validator.validate( params ) 
     352 
     353        @validator.should be_okay() 
     354        @validator.should_not have_errors() 
     355 
     356        @validator[:bool_constraint].should be_true() 
     357    end 
     358     
    348359    it "accepts the value 'false' for fields with boolean constraints" do 
    349360        params = {'required' => '1', 'bool_constraint' => 'false'} 
     
    381392    it "accepts the value 'n' for fields with boolean constraints" do 
    382393        params = {'required' => '1', 'bool_constraint' => 'n'} 
     394     
     395        @validator.validate( params ) 
     396 
     397        @validator.should be_okay() 
     398        @validator.should_not have_errors() 
     399 
     400        @validator[:bool_constraint].should be_false() 
     401    end 
     402 
     403    it "accepts the value '0' for fields with boolean constraints" do 
     404        params = {'required' => '1', 'bool_constraint' => '0'} 
    383405     
    384406        @validator.validate( params )