Validator — Documentation by YARD 0.9.37 (original) (raw)
Module: Mongo::Address::ValidatorPrivate
Included in:
Defined in:
lib/mongo/address/validator.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Instance Method Summarycollapse
- #validate_address_str!(address_str) ⇒ Object private
Takes an address string in ipv4/ipv6/hostname/socket path format and validates its format.
Instance Method Details
#validate_address_str!(address_str) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Takes an address string in ipv4/ipv6/hostname/socket path format and validates its format.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | # File 'lib/mongo/address/validator.rb', line 27 def validate_address_str!(address_str) case address_str when /\A\[[\d:]+\](?::(\d+))?\z/ if port_str = $1 validate_port_str!(port_str) end when /\A\//, /\.sock\z/ when /[\/\[\]]/ raise Error::InvalidAddress, "Invalid hostname: #{address_str}" when /:.*:/m raise Error::InvalidAddress, "Multiple port delimiters are not allowed: #{address_str}" else host, port = address_str.split(':') if host.empty? raise Error::InvalidAddress, "Host is empty: #{address_str}" end validate_hostname!(host) if port && port.empty? raise Error::InvalidAddress, "Port is empty: #{address_str}" end validate_port_str!(port) end end |
---|