Module: Validators

Defined in:
lib/validators.rb,
lib/validators/ip.rb,
lib/validators/version.rb,
lib/validators/constants.rb

Defined Under Namespace

Modules: Ip, Version

Constant Summary collapse

EMAIL_FORMAT =
/\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
IPv4_PART =
/\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]/
URL_FORMAT =
%r[
  \A
  https?://                                                    # http:// or https://
  ([^\s:@]+:[^\s:@]*@)?                                        # optional username:pw@
  ( (([^\W_]+\.)*xn--)?[^\W_]+([-.][^\W_]+)*\.[a-z]{2,6}\.? |  # domain (including Punycode/IDN)...
      #{IPv4_PART}(\.#{IPv4_PART}){3} )                        # or IPv4
  (:\d{1,5})?                                                  # optional port
  ([/?]\S*)?                                                   # optional /whatever or ?whatever
  \z
]ixs