Class: Axlsx::RegexValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/axlsx/util/validators.rb

Overview

Validates the value against the regular expression provided.

Class Method Summary collapse

Class Method Details

.validate(name, regex, v) ⇒ Object

Parameters:

  • name (String)

    The name of what is being validated. This is included in the output when the value is invalid

  • regex (Regexp)

    The regular expression to evaluate

  • v (Any)

    The value to validate.

Raises:

  • (ArgumentError)


43
44
45
# File 'lib/axlsx/util/validators.rb', line 43

def self.validate(name, regex, v)
  raise ArgumentError, format(ERR_REGEX, v.inspect, regex.to_s) unless v.respond_to?(:to_s) && regex.match?(v.to_s)
end