Skip to content

Commit b2b5001

Browse files
authored
fix: include period in name validation error message (#6366)
The error message for invalid gem names listed only "letters, numbers, dashes, and underscores" as allowed characters, but `Patterns::NAME_PATTERN` also permits periods via `SPECIAL_CHARACTERS`. Updated the message and corresponding test assertion to include "periods" for consistency. Fixes #6349 Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
1 parent 333af6c commit b2b5001

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

lib/name_format_validator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def validate_each(record, attribute, value)
55
return record.errors.add attribute, "must be a String" if value.class != String
66

77
record.errors.add attribute, "must include at least one letter" if requires_letter? && !Patterns::LETTER_REGEXP.match?(value)
8-
record.errors.add attribute, "can only include letters, numbers, dashes, and underscores" unless Patterns::NAME_PATTERN.match?(value)
8+
record.errors.add attribute, "can only include letters, numbers, periods, dashes, and underscores" unless Patterns::NAME_PATTERN.match?(value)
99
record.errors.add attribute, "can not begin with a period, dash, or underscore" if Patterns::SPECIAL_CHAR_PREFIX_REGEXP.match?(value)
1010
record.errors.add attribute, "can not end with a period, dash, or underscore" if Patterns::SPECIAL_CHAR_SUFFIX_REGEXP.match?(value)
1111
record.errors.add attribute, "can not end with a common file extension" if Patterns::BANNED_EXTENSION_REGEXP.match?(value)

test/integration/pusher_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class PusherIntegrationTest < ActiveSupport::TestCase
134134
@cutter = Pusher.new(@api_key, @gem)
135135
@cutter.process
136136

137-
assert_match(/Dependency unresolved name can only include letters, numbers, dashes, and underscores/, @cutter.message)
137+
assert_match(/Dependency unresolved name can only include letters, numbers, periods, dashes, and underscores/, @cutter.message)
138138
assert_equal 403, @cutter.code
139139
end
140140

0 commit comments

Comments
 (0)