Class Index [+]

Quicksearch

DataMapper::Validations::ValidatesConfirmation

Public Instance Methods

validates_confirmation_of(*fields) click to toggle source

Validates that the given attribute is confirmed by another attribute. A common use case scenario is when you require a user to confirm their password, for which you use both password and password_confirmation attributes.

@option [Boolean] :allow_nil (true)

  true or false.

@option [Boolean] :allow_blank (true)

  true or false.

@option [Symbol] :confirm (firstattr_confirmation)

  The attribute that you want to validate against.

@example Usage

  require 'dm-validations'

  class Page
    include DataMapper::Resource

    property :password, String
    property :email, String
    attr_accessor :password_confirmation
    attr_accessor :email_repeated

    validates_confirmation_of :password
    validates_confirmation_of :email, :confirm => :email_repeated

    # a call to valid? will return false unless:
    # password == password_confirmation
    # and
    # email == email_repeated
    # File lib/dm-validations/validators/confirmation_validator.rb, line 84
84:       def validates_confirmation_of(*fields)
85:         validators.add(ConfirmationValidator, *fields)
86:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.