class Bodhi::UrlValidator
Public Class Methods
new(value)
click to toggle source
# File lib/bodhi-slam/validators/url.rb, line 4 def initialize(value); end
Public Instance Methods
to_options()
click to toggle source
# File lib/bodhi-slam/validators/url.rb, line 20 def to_options {self.to_sym => true} end
validate(record, attribute, value)
click to toggle source
# File lib/bodhi-slam/validators/url.rb, line 6 def validate(record, attribute, value) unless value.nil? if value.is_a?(Array) unless value.empty? record.errors.add(attribute, "must contain only valid URLs") unless value.delete_if{ |v| v =~ /\A#{URI::regexp}\z/ }.empty? end else record.errors.add(attribute, "must be a valid URL") unless value =~ /\A#{URI::regexp}\z/ end end end