Sha256: 408a188fefae9ff2cf79910e8909460be7ab41447f782a727c39fd7f7ac426d8

Contents?: true

Size: 516 Bytes

Versions: 13

Compression:

Stored size: 516 Bytes

Contents

class BazaModels::Validators::ConfirmationValidator < BazaModels::Validators::BaseValidator
  def validate(model, value)
    confirmation_attribute_name = "#{attribute_name}_confirmation"
    confirmation_value = model.__send__(confirmation_attribute_name)

    if value && !confirmation_value
      model.errors.add(attribute_name, "hasn't been confirmed")
    end

    model.errors.add(attribute_name, "was not the same as the confirmation") if value && confirmation_value && confirmation_value != value
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
baza_models-0.0.13 lib/baza_models/validators/confirmation_validator.rb
baza_models-0.0.12 lib/baza_models/validators/confirmation_validator.rb
baza_models-0.0.11 lib/baza_models/validators/confirmation_validator.rb
baza_models-0.0.10 lib/baza_models/validators/confirmation_validator.rb
baza_models-0.0.9 lib/baza_models/validators/confirmation_validator.rb
baza_models-0.0.8 lib/baza_models/validators/confirmation_validator.rb
baza_models-0.0.7 lib/baza_models/validators/confirmation_validator.rb
baza_models-0.0.6 lib/baza_models/validators/confirmation_validator.rb
baza_models-0.0.5 lib/baza_models/validators/confirmation_validator.rb
baza_models-0.0.4 lib/baza_models/validators/confirmation_validator.rb
baza_models-0.0.3 lib/baza_models/validators/confirmation_validator.rb
baza_models-0.0.2 lib/baza_models/validators/confirmation_validator.rb
baza_models-0.0.1 lib/baza_models/validators/confirmation_validator.rb