Sha256: d3716a88c82b50dd9a438ddfa47184ec49f254c2a51fa418b98a667bc4615f45
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
require 'whyvalidationssuckin96/skippable_validation' require 'whyvalidationssuckin96/attribute_based_validation' module WhyValidationsSuckIn96 # Checks the validity of an attribute against a confirmation field. Note that this validation does # not set up the confirmation field on the object, leaving this up to the implementer. # # @example Default usage # class Account # attr_accessor :password, :password_confirmation # setup_validations do # validates_confirmation_of :password # end # end class ValidatesConfirmation < Validation include WhyValidationsSuckIn96::SkippableValidation include WhyValidationsSuckIn96::AttributeBasedValidation DefaultOptions = {:message => "does not match the confirmation"} def validate super skip unless confirmation_value = validatable.send(confirmation_field) if confirmation_value == attribute_value pass else fail end end private def confirmation_field :"#{attribute}_confirmation" end end # Validation ValidationBuilder.register_macro :validates_confirmation_of, WhyValidationsSuckIn96::ValidatesConfirmation end # WhyValidationsSuckIn96
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
whyvalidationssuckin96-1.6.4 | lib/whyvalidationssuckin96/macros/validates_confirmation.rb |