Skip to content

Commit

Permalink
Refactor Service::NameValidator#valid_name?
Browse files Browse the repository at this point in the history
  • Loading branch information
vpereira committed Oct 19, 2020
1 parent 6ffda9d commit 3c26475
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/api/app/models/service/name_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ def valid?
private

def valid_name?
return false unless name.is_a?(String)
return false if name.length > 200 || name.blank?
return false if /^[_.]/.match?(name)
return false if /::/.match?(name)
return true if /\A\w[-+\w.:]*\z/.match?(name)
return false unless name.present? || name.is_a?(String)
return false if name.length > 200

false
case name
when /^[_.]/, /::/
false
when /\A\w[-+\w.:]*\z/
true
else
false
end
end
end
end

0 comments on commit 3c26475

Please sign in to comment.