class URI::GID

def validate_app(app)

URI::GID.validate_app('foo/bar') # => ArgumentError
URI::GID.validate_app(nil) # => ArgumentError

URI::GID.validate_app('foo-bar') # => 'foo-bar'
URI::GID.validate_app('bcx') # => 'bcx'

and hyphens. An ArgumentError is raised if +app+ is invalid.
Validates +app+'s as URI hostnames containing only alphanumeric characters
def validate_app(app)
  parse("gid://#{app}/Model/1").app
rescue URI::Error
  raise ArgumentError, 'Invalid app name. ' \
    'App names must be valid URI hostnames: alphanumeric and hyphen characters only.'
end