validates :my_url, format: {with: URI::DEFAULT_PARSER.make_regexp}, if: proc { |o| o.my_url.present? }
Or, with the gem https://github.com/perfectline/validates_url
validates :my_url, url: { allow_blank: true }
Feb 14, 2025
validates :my_url, format: {with: URI::DEFAULT_PARSER.make_regexp}, if: proc { |o| o.my_url.present? }
Or, with the gem https://github.com/perfectline/validates_url
validates :my_url, url: { allow_blank: true }