class InputSanitizer::V2::Types::URLCheck
Public Instance Methods
call(value, options = {})
click to toggle source
# File lib/input_sanitizer/v2/types.rb, line 165 def call(value, options = {}) if value.blank? && (options[:allow_blank] == false || options[:required] == true) raise InputSanitizer::BlankValueError elsif value == nil && options[:allow_nil] == false raise InputSanitizer::BlankValueError elsif value.blank? value else unless /\A#{URI.regexp(%w(http https)).to_s}\z/.match(value) raise InputSanitizer::TypeMismatchError.new(value, :url) end value end end