From fabe7d771f5064b60aa68706ed0ea49b5d3ecc3d Mon Sep 17 00:00:00 2001 From: Randy Morgan Date: Thu, 3 May 2012 18:41:43 +0900 Subject: use string casting and matching for regex validations. --- lib/axlsx/util/validators.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/axlsx/util/validators.rb b/lib/axlsx/util/validators.rb index 5dc1f66e..48f99877 100644 --- a/lib/axlsx/util/validators.rb +++ b/lib/axlsx/util/validators.rb @@ -20,7 +20,7 @@ module Axlsx # @param [Regexp] regex The regular expression to evaluate # @param [Any] v The value to validate. def self.validate(name, regex, v) - raise ArgumentError, (ERR_REGEX % [v.inspect, regex.to_s]) unless (v.respond_to?(:=~) && v =~ regex) + raise ArgumentError, (ERR_REGEX % [v.inspect, regex.to_s]) unless (v.respond_to?(:to_s) && v.to_s.match(regex)) end end # Validate that the class of the value provided is either an instance or the class of the allowed types and that any specified additional validation returns true. -- cgit v1.2.3