Module: Cipher::Validator

Included in:
Cipher
Defined in:
lib/cipher/validator.rb

Instance Method Summary collapse

Instance Method Details

#validate(args = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/cipher/validator.rb', line 3

def validate(args = {})
  unique = args[:unique]
  key = args[:key]
  
  if unique.nil? || key.nil?
    raise ArgumentError, 'You need to pass a hash with a unique string and a key to validate'
  end
  
  generate({ unique: unique }) == key
end