#184 ✓resolved
Camilo Lopez

property ... :nullable => true will raise NoMethodError

Reported by Camilo Lopez | March 19th, 2008 @ 03:57 PM

To reproduce:

class M < DataMapper::Base
  property :name, :string, :nullable => true
end

The problems is nullable autovalidation lambda function will return nil when nullable != false

From lib/datamaper/property.rb


  # NOTE: :length may also be used in place of :size 
    AUTO_VALIDATIONS = {
      :nullable => lambda { |k,v| "validates_presence_of :#{k}" if v == false },
      :size => lambda { |k,v| "validates_length_of :#{k}, " + (v.is_a?(Range) ? ":minimum => #{v.first}, :maximum => #{v.last}" : ":maximum => #{v}") },
      :format => lambda { |k, v| "validates_format_of :#{k}, :with => #{v.inspect}" }
    }

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

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 »

Pages