Module: DataMapper::Validations

### Home Classes Methods

### In Files

- lib/dm-validations.rb
- lib/dm-validations/auto_validate.rb
- lib/dm-validations/context.rb
- lib/dm-validations/contextual_validators.rb
- lib/dm-validations/formats/email.rb
- lib/dm-validations/formats/url.rb
- lib/dm-validations/support/ordered_hash.rb
- lib/dm-validations/validation_errors.rb
- lib/dm-validations/validators/absent_field_validator.rb
- lib/dm-validations/validators/acceptance_validator.rb
- lib/dm-validations/validators/block_validator.rb
- lib/dm-validations/validators/confirmation_validator.rb
- lib/dm-validations/validators/format_validator.rb
- lib/dm-validations/validators/generic_validator.rb
- lib/dm-validations/validators/length_validator.rb
- lib/dm-validations/validators/method_validator.rb
- lib/dm-validations/validators/numeric_validator.rb
- lib/dm-validations/validators/primitive_validator.rb
- lib/dm-validations/validators/required_field_validator.rb
- lib/dm-validations/validators/uniqueness_validator.rb
- lib/dm-validations/validators/within_validator.rb

### Namespace

- MODULE DataMapper::Validations::AutoValidations
- MODULE DataMapper::Validations::ClassMethods
- MODULE DataMapper::Validations::Context
- MODULE DataMapper::Validations::Format
- MODULE DataMapper::Validations::ValidatesAbsence
- MODULE DataMapper::Validations::ValidatesAcceptance
- MODULE DataMapper::Validations::ValidatesConfirmation
- MODULE DataMapper::Validations::ValidatesFormat
- MODULE DataMapper::Validations::ValidatesLength
- MODULE DataMapper::Validations::ValidatesNumericality
- MODULE DataMapper::Validations::ValidatesPresence
- MODULE DataMapper::Validations::ValidatesPrimitiveType
- MODULE DataMapper::Validations::ValidatesUniqueness
- MODULE DataMapper::Validations::ValidatesWithBlock
- MODULE DataMapper::Validations::ValidatesWithMethod
- MODULE DataMapper::Validations::ValidatesWithin
- CLASS DataMapper::Validations::AbsenceValidator
- CLASS DataMapper::Validations::AcceptanceValidator
- CLASS DataMapper::Validations::ConfirmationValidator
- CLASS DataMapper::Validations::ContextualValidators
- CLASS DataMapper::Validations::FormatValidator
- CLASS DataMapper::Validations::GenericValidator
- CLASS DataMapper::Validations::LengthValidator
- CLASS DataMapper::Validations::MethodValidator
- CLASS DataMapper::Validations::NumericalityValidator
- CLASS DataMapper::Validations::OrderedHash
- CLASS DataMapper::Validations::PresenceValidator
- CLASS DataMapper::Validations::PrimitiveTypeValidator
- CLASS DataMapper::Validations::UniquenessValidator
- CLASS DataMapper::Validations::UnknownValidationFormat
- CLASS DataMapper::Validations::ValidationErrors
- CLASS DataMapper::Validations::WithinValidator

### Methods

- ::included
- #errors
- #save
- #save_self
- #update
- #valid?
- #valid_for_default?
- #validatable?
- #validation_property_value

### Included Modules

- DataMapper::Validations::Context

### Files

- LICENSE
- README.rdoc

### Class/Module Index

Quicksearch

- DataMapper
- DataMapper::InvalidContextError
- DataMapper::Validate
- DataMapper::ValidationError
- DataMapper::Validations
- DataMapper::Validations::AbsenceValidator
- DataMapper::Validations::AcceptanceValidator
- DataMapper::Validations::AutoValidations
- DataMapper::Validations::AutoValidations::ModelExtension
- DataMapper::Validations::ClassMethods
- DataMapper::Validations::ConfirmationValidator
- DataMapper::Validations::Context
- DataMapper::Validations::ContextualValidators
- DataMapper::Validations::Format
- DataMapper::Validations::Format::Email
- DataMapper::Validations::Format::Url
- DataMapper::Validations::FormatValidator
- DataMapper::Validations::GenericValidator
- DataMapper::Validations::LengthValidator
- DataMapper::Validations::MethodValidator
- DataMapper::Validations::NumericalityValidator
- DataMapper::Validations::OrderedHash
- DataMapper::Validations::PresenceValidator
- DataMapper::Validations::PrimitiveTypeValidator
- DataMapper::Validations::UniquenessValidator
- DataMapper::Validations::UnknownValidationFormat
- DataMapper::Validations::ValidatesAbsence
- DataMapper::Validations::ValidatesAcceptance
- DataMapper::Validations::ValidatesConfirmation
- DataMapper::Validations::ValidatesFormat
- DataMapper::Validations::ValidatesLength
- DataMapper::Validations::ValidatesNumericality
- DataMapper::Validations::ValidatesPresence
- DataMapper::Validations::ValidatesPrimitiveType
- DataMapper::Validations::ValidatesUniqueness
- DataMapper::Validations::ValidatesWithBlock
- DataMapper::Validations::ValidatesWithMethod
- DataMapper::Validations::ValidatesWithin
- DataMapper::Validations::ValidationErrors
- DataMapper::Validations::WithinValidator
- Object

No matching classes.

# DataMapper::Validations

### Public Class Methods

included(model) click to toggle source

    # File lib/dm-validations.rb, line 30
    def self.included(model)
      model.extend ClassMethods
    end

### Public Instance Methods

errors() click to toggle source

Return the ValidationErrors

@api public

    # File lib/dm-validations.rb, line 61
    def errors
      @errors ||= ValidationErrors.new(self)
    end

save(context = default_validation_context) click to toggle source

Ensures the object is valid for the context provided, and otherwise throws :halt and returns false.

@api public

    # File lib/dm-validations.rb, line 38
    def save(context = default_validation_context)
      model.validators.assert_valid(context)
      Validations::Context.in_context(context) { super() }
    end

save_self(*) click to toggle source

@api private

    # File lib/dm-validations.rb, line 50
    def save_self(*)
      if Validations::Context.any? && !valid?(model.validators.current_context)
        false
      else
        super
      end
    end

update(attributes = {}, context = default_validation_context) click to toggle source

@api public

    # File lib/dm-validations.rb, line 44
    def update(attributes = {}, context = default_validation_context)
      model.validators.assert_valid(context)
      Validations::Context.in_context(context) { super(attributes) }
    end

valid?(context = :default) click to toggle source

Check if a resource is valid in a given context

@api public

    # File lib/dm-validations.rb, line 84
    def valid?(context = :default)
      model = respond_to?(:model) ? self.model : self.class
      model.validators.execute(context, self)
    end

valid_for_default?() click to toggle source

Alias for valid?(:default)

TODO: deprecate

    # File lib/dm-validations.rb, line 77
    def valid_for_default?
      valid?(:default)
    end

validatable?() click to toggle source

Mark this resource as validatable. When we validate associations of a resource we can check if they respond to validatable? before trying to recursively validate them

@api semipublic

    # File lib/dm-validations.rb, line 70
    def validatable?
      true
    end

validation_property_value(name) click to toggle source

@api semipublic

    # File lib/dm-validations.rb, line 90
    def validation_property_value(name)
      __send__(name) if respond_to?(name, true)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.