Module: Virgil::Crypto::Validation

Defined in:
lib/virgil/crypto/validation.rb

Class Method Summary collapse

Class Method Details

.check_array_argument!(val) ⇒ Object

Raises:

  • (TypeError)


38
39
40
41
42
# File 'lib/virgil/crypto/validation.rb', line 38

def self.check_array_argument!(val)
  raise TypeError, 'argument must be an array' unless val.is_a?(Array)

  val
end

.check_filled_array_argument!(val) ⇒ Object

Raises:

  • (ArgumentError)


44
45
46
47
48
49
# File 'lib/virgil/crypto/validation.rb', line 44

def self.check_filled_array_argument!(val)
  check_array_argument!(val)
  raise ArgumentError, 'argument must not be an empty array' if val.empty?

  val
end

.check_type_argument!(cclass, val) ⇒ Object

Raises:

  • (TypeError)


51
52
53
54
55
# File 'lib/virgil/crypto/validation.rb', line 51

def self.check_type_argument!(cclass, val)
  raise TypeError, "argument must have type #{cclass.name}" unless val.is_a?(cclass)

  val
end