Hi everyone,

Auto validation on primary keys sucks because they often aren't know at validation time (such as creating new objects in a tree - the children don't know the FK, which is often a part of the PK, until after validation and after save of the parent).

I am using the following monkey patch in my current project to default auto_validation on PKs to false, but still allow it to be overridden to true. How do people feel about making it default behaviour?

module DataMapper
  module Validations
    module AutoValidations
      def skip_auto_validation_for?(property)
        (property.key? && !property.options[:auto_validation]) ||
(property.options.key?(:auto_validation) && !property.options[:auto_validation])
      end
    end
  end
end

Another behaviour I've noted is that :auto_validation on a belongs_to isn't passed down to the properties, but I think this is a real bug so will put together a proper test case/patch for it.

Xavier

--
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to