Module: DataMapper::Validate::AutoValidate

Module | DataMapper::Validate::AutoValidate
In: | lib/dm-validations/auto_validate.rb

### Methods

auto_generate_validations auto_validations_disabled? disabled_auto_validations? infer_format_validation_for infer_length_validation_for infer_presence_validation_for infer_type_validation_for infer_uniqueness_validation_for infer_within_validation_for options_with_message skip_auto_validation_for? without_auto_validations

### Attributes

disable_auto_validations | [R] |

### Public Instance methods

auto_generate_validations(property)

Auto-generate validations for a given property. This will only occur if the option :auto_validation is either true or left undefined.

@details [Triggers]

      Triggers that generate validator creation

      :nullable => false
          Setting the option :nullable to false causes a
          validates_presence_of validator to be automatically created on
          the property

      :length => 20
          Setting the option :length causes a validates_length_of
          validator to be automatically created on the property. If the
          value is a Integer the validation will set :maximum => value if
          the value is a Range the validation will set :within => value

      :format => :predefined / lambda / Proc
          Setting the :format option causes a validates_format_of
          validator to be automatically created on the property

      :set => ["foo", "bar", "baz"]
          Setting the :set option causes a validates_within
          validator to be automatically created on the property

      Integer type
          Using a Integer type causes a validates_is_number
          validator to be created for the property.  integer_only
          is set to true

      BigDecimal or Float type
          Using a Integer type causes a validates_is_number
          validator to be created for the property.  integer_only
          is set to false, and precision/scale match the property

      Messages

      :messages => {..}
          Setting :messages hash replaces standard error messages
          with custom ones. For instance:
          :messages => {:presence => "Field is required",
                        :format => "Field has invalid format"}
          Hash keys are: :presence, :format, :length, :is_unique,
                         :is_number, :is_primitive

      :message => "Some message"
          It is just shortcut if only one validation option is set

auto_validations_disabled?()

Alias for disabled_auto_validations?

disabled_auto_validations?()

Checks whether auto validations are currently disabled (see `disable_auto_validations` method that takes a block)

@return [TrueClass, FalseClass]

      true if auto validation is currently disabled

infer_format_validation_for(property, options)
infer_length_validation_for(property, options)
infer_presence_validation_for(property, options)
infer_type_validation_for(property, options)
infer_uniqueness_validation_for(property, options)
infer_within_validation_for(property, options)
options_with_message(base_options, property, validator_name)

adds message for validator

skip_auto_validation_for?(property)

Checks whether or not property should be auto validated. It is the case for properties with :auto_validation option given and it‘s value evaluates to true

@return [TrueClass, FalseClass]

      true for properties with :auto_validation option that has positive value

without_auto_validations(&block)

disables generation of validations for duration of given block

[Validate]