Class: PasswordConfirmationValidation

Inherits:
Validation
  • Object
show all
Defined in:
lib/yodel/models/core/validations/password_confirmation_validation.rb

Instance Attribute Summary

Attributes inherited from Validation

#field, #params

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Validation

#initialize, #to_json

Constructor Details

This class inherits a constructor from Validation

Class Method Details

.validate(params, field, name, value, record, errors) ⇒ Object



2
3
4
5
6
# File 'lib/yodel/models/core/validations/password_confirmation_validation.rb', line 2

def self.validate(params, field, name, value, record, errors)
  return if record.field_was(field.name).nil? || record.stash["current_#{name}"].nil? || !record.respond_to?(:passwords_match?)
  match = record.passwords_match?(record.stash["current_#{name}"])
  errors[field.name] << new(name) unless match
end

Instance Method Details

#describeObject



8
9
10
# File 'lib/yodel/models/core/validations/password_confirmation_validation.rb', line 8

def describe
  "didn't match your existing #{params}"
end