Skip to content

Commit

Permalink
[dm-validations] Validate presence only when Property#allow_blank? is…
Browse files Browse the repository at this point in the history
… true

[#935]
  • Loading branch information
dkubb committed Nov 11, 2009
1 parent c0a32dc commit 9203331
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions dm-validations/lib/dm-validations/auto_validate.rb
Expand Up @@ -111,8 +111,8 @@ def auto_generate_validations(property)
def disabled_auto_validations?
@disable_auto_validations || false
end
alias auto_validations_disabled? disabled_auto_validations?

alias auto_validations_disabled? disabled_auto_validations?

# Checks whether or not property should be auto validated.
# It is the case for properties with :auto_validation option
Expand All @@ -125,7 +125,7 @@ def skip_auto_validation_for?(property)
end

def infer_presence_validation_for(property, options)
return if allow_nil?(property)
return if skip_presence_validation?(property)

validates_present property.name, options_with_message(options, property, :presence)
end
Expand Down Expand Up @@ -193,8 +193,8 @@ def infer_type_validation_for(property, options)

private

def allow_nil?(property)
property.allow_nil? || property.serial?
def skip_presence_validation?(property)
property.allow_blank? || property.serial?
end
end # module AutoValidate
end # module Validate
Expand Down

0 comments on commit 9203331

Please sign in to comment.