<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>TODO</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -14,7 +14,7 @@ spec = Gem::Specification.new do |s|
   s.version = VERSION
   s.platform = Gem::Platform::RUBY
   s.has_rdoc = true
-  s.extra_rdoc_files = [&quot;README&quot;, &quot;LICENSE&quot;, 'TODO']
+  s.extra_rdoc_files = [&quot;README&quot;, &quot;LICENSE&quot;, &quot;TODO&quot;]
   s.summary = SUMMARY
   s.description = s.summary
   s.author = AUTHOR</diff>
      <filename>dm-validations/Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -94,7 +94,7 @@ module DataMapper
       
       
       def validation_property_value(name)
-        return self.instance_variable_get(&quot;@#{name}&quot;) if self.class.properties(self.class.repository.name)[name]
+        return self.instance_variable_get(&quot;@#{name}&quot;) if self.instance_variables.include?(name)
         return self.send(name) if self.respond_to?(name)
         nil
       end</diff>
      <filename>dm-validations/lib/dm-validations.rb</filename>
    </modified>
    <modified>
      <diff>@@ -46,7 +46,8 @@ module DataMapper
             if property.options.has_key?(:length) || property.options.has_key?(:size)
               len = property.options.has_key?(:length) ? property.options[:length] : property.options[:size]
               opts[:within] = len if len.is_a?(Range)
-              opts[:maximum] = len unless len.is_a?(Range)
+              opts[:maximum] = len unless len.is_a?(Range)              
+              opts[:allow_nil] = property.options[:nullable] if property.options.has_key?(:nullable)              
               validates_length_of property.name, opts
             else
               opts[:maximum] = 50 #default string size</diff>
      <filename>dm-validations/lib/dm-validations/auto_validate.rb</filename>
    </modified>
    <modified>
      <diff>@@ -20,9 +20,11 @@ module DataMapper
       end
       
       def call(target)
-        field_value = target.instance_variable_get(&quot;@#{@field_name}&quot;).to_s
+        field_value = target.validation_property_value(@field_name) 
         return true if @options[:allow_nil] &amp;&amp; field_value.nil?
         
+        field_value = '' if field_value.nil?
+        
         # HACK seems hacky to do this on every validation, probably should do this elsewhere?
         field = DataMapper::Inflection.humanize(@field_name)
         min = @range ? @range.min : @min</diff>
      <filename>dm-validations/lib/dm-validations/length_validator.rb</filename>
    </modified>
    <modified>
      <diff>@@ -8,9 +8,12 @@ module DataMapper
         @field_name, @options = field_name, options
       end
       
-      def call(target)
-        field_value = !target.instance_variable_get(&quot;@#{@field_name}&quot;).blank?
-        return true if field_value
+      def call(target)        
+        if @field_name == 'customer'
+          puts @field_name
+        end
+        value = target.validation_property_value(@field_name)
+        return true if !value.blank?
         
         error_message = @options[:message] || &quot;%s must not be blank&quot;.t(DataMapper::Inflection.humanize(@field_name))
         add_error(target, error_message , @field_name)</diff>
      <filename>dm-validations/lib/dm-validations/required_field_validator.rb</filename>
    </modified>
    <modified>
      <diff>@@ -18,7 +18,7 @@ module DataMapper
           scope.map do |item|
             if !target.class.properties(target.class.repository.name)[item].nil?
               opts[item] = target.validation_property_value(item) 
-            elsif target.class.relationships.include?(item)
+            elsif target.class.relationships.has_key?(item) #include?(item) #TODO I chaned this to has_key? check!!!!
               target.validation_association_keys(item).map do |key|
                 opts[key] = target.validation_property_value(key)
               end</diff>
      <filename>dm-validations/lib/dm-validations/uniqueness_validator.rb</filename>
    </modified>
    <modified>
      <diff>@@ -276,6 +276,7 @@ begin
           property :no_validation, String, :auto_validation =&gt; false
           property :salesman, String, :nullable =&gt; false, :validates =&gt; [:multi_context_1, :multi_context_2]
           property :code, String, :format =&gt; Proc.new { |code| code =~ /A\d{4}/}, :validates =&gt; :format_test
+          property :allow_nil, String, :size =&gt; 5..10, :nullable =&gt; true, :validates =&gt; :nil_test
         end
       end
     
@@ -347,6 +348,24 @@ begin
         end
         Test.new().valid?().should == true
       end
+      
+      it 'It should auto add range checking the length of a string while still allowing null values' do
+        boat = SailBoat.new()
+        boat.allow_nil = 'ABC'
+        boat.should_not be_valid_for_nil_test
+        boat.errors.on(:allow_nil).should include('Allow nil must be between 5 and 10 characters long')
+        
+        boat.allow_nil = 'ABCDEFG'
+        boat.should be_valid_for_nil_test
+
+        boat.allow_nil = 'ABCDEFGHIJKLMNOP'
+        boat.should_not be_valid_for_nil_test
+        boat.errors.on(:allow_nil).should include('Allow nil must be between 5 and 10 characters long')
+        
+        boat.allow_nil = nil
+        boat.should be_valid_for_nil_test
+              
+      end
           
     end
   end
@@ -354,25 +373,64 @@ begin
   #-----------------------------------------------------------------------------
 
   describe DataMapper::Validate::RequiredFieldValidator do
-    before(:all) do
-      class Boat
+    after do
+      repository(:sqlite3).adapter.execute('DROP TABLE &quot;landscapers&quot;');
+      repository(:sqlite3).adapter.execute('DROP TABLE &quot;gardens&quot;');
+    end
+    
+    before do
+      repository(:sqlite3).adapter.execute(&lt;&lt;-EOS.compress_lines) rescue nil
+        CREATE TABLE &quot;landscapers&quot; (
+          &quot;id&quot; INTEGER PRIMARY KEY,
+          &quot;name&quot; VARCHAR(50)
+        )
+      EOS
+      repository(:sqlite3).adapter.execute(&lt;&lt;-EOS.compress_lines) rescue nil
+        CREATE TABLE &quot;gardens&quot; (
+          &quot;id&quot; INTEGER PRIMARY KEY,
+          &quot;landscaper_id&quot; INTEGER,
+          &quot;name&quot; VARCHAR(50)
+        )
+      EOS
+      
+      class Landscaper
+        include DataMapper::Resource
+        include DataMapper::Validate
+        property :id, Fixnum, :key =&gt; true
+        property :name, String        
+      end
+      
+      class Garden
         include DataMapper::Resource
         include DataMapper::Validate
+        property :id, Fixnum, :key =&gt; true
+        property :landscaper_id, Fixnum
         property :name, String, :auto_validation =&gt; false                  
-        validates_presence_of :name    
+        
+        has :landscaper, 1..n
+        
+        validates_presence_of :name, :when =&gt; :property_test    
+        validates_presence_of :landscaper, :when =&gt; :association_test    
       end
     end
 
-    it &quot;should validate the presence of a value on an instance of a resource&quot; do
-      sting_ray = Boat.new
-      sting_ray.valid?.should_not == true
-      sting_ray.errors.full_messages.include?('Name must not be blank').should == true
+    it &quot;should validate the presence of a property value on an instance of a resource&quot; do
+      garden = Garden.new
+      garden.should_not be_valid_for_property_test
+      garden.errors.on(:name).should include('Name must not be blank')
       
-      sting_ray.name = 'Sting Ray'
-      sting_ray.valid?.should == true
-      sting_ray.errors.full_messages.length.should == 0  
+      garden.name = 'The Wilds'
+      garden.should be_valid_for_property_test
     end
     
+    it &quot;should validate the presence of an association value on an instance of a resource&quot; 
+    #do
+    #  garden = Garden.new
+    #  landscaper = garden.landscaper
+    #  puts landscaper.children.length
+    #  #puts &quot;Gardens landscaper is #{garden.landscaper.child_key}&quot;
+    #end
+    
   end
 
 </diff>
      <filename>dm-validations/spec/validation_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>09e2bca4833702719797f68c8c5dba42f275632c</id>
    </parent>
  </parents>
  <author>
    <name>Guy van den Berg</name>
    <email>vandenberg.guy@gmail.com</email>
  </author>
  <url>http://github.com/datamapper/dm-more/commit/fbf2bd1964b65dc94e38f55485f8a8e834596f6f</url>
  <id>fbf2bd1964b65dc94e38f55485f8a8e834596f6f</id>
  <committed-date>2008-04-15T22:30:10-07:00</committed-date>
  <authored-date>2008-04-15T22:30:10-07:00</authored-date>
  <message>Validation bug fixes
  * Fixed ticket 204
  * Clean up Rakefile
  * Retrieve value of field in more consistent way</message>
  <tree>6a3ece177992287414318bd0d69b719b4e325dde</tree>
  <committer>
    <name>Guy van den Berg</name>
    <email>vandenberg.guy@gmail.com</email>
  </committer>
</commit>
