We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Util.valid_variable_name?
1 parent d7315e3 commit 4aa4476Copy full SHA for 4aa4476
lib/stripe/util.rb
@@ -4,9 +4,6 @@
4
5
module Stripe
6
module Util
7
- LEGAL_FIRST_CHARACTER = /[a-zA-Z_]/.freeze
8
- LEGAL_VARIABLE_CHARACTER = /[a-zA-Z0-9_]/.freeze
9
-
10
def self.objects_to_ids(obj)
11
case obj
12
when APIResource
@@ -323,9 +320,7 @@ def self.normalize_opts(opts)
323
320
# Return false for strings that are invalid variable names
324
321
# Does NOT expect there to be a preceding '@' for instance variables
325
322
def self.valid_variable_name?(key)
326
- return false if key.empty? || key[0] !~ LEGAL_FIRST_CHARACTER
327
328
- key[1..].chars.all? { |char| char =~ LEGAL_VARIABLE_CHARACTER }
+ key.match?(/\A[a-zA-Z_]\w*\z/)
329
end
330
331
def self.check_string_argument!(key)
0 commit comments