Class: WalletExistsValidator

Inherits:
ActiveModel::Validator
  • Object
show all
Defined in:
app/models/concerns/wallet_exists_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate(record) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'app/models/concerns/wallet_exists_validator.rb', line 4

def validate(record)
  if Wallet.find_by(pr_key: record.receiver_key).nil?
    record.errors[:sender_key] << "Sender key is not valid"
  end

  if Wallet.find_by(pv_key: record.sender_key).nil?
    record.errors[:receiver_key] << "Receiver key is not valid"
  end
end