class EmailValidator
Attributes
default_parser_options[RW]
Public Class Methods
new(*_args)
click to toggle source
Calls superclass method
# File lib/email_parser/validator.rb, line 11 def initialize(*_args) super parser_options = options.each_with_object({}) do |(k, v), h| h[k] = v if EmailParser::OPTIONS.include?(k) end @parser = EmailParser.new(**self.class.default_parser_options.merge(parser_options)) end
Public Instance Methods
validate_each(record, attribute, value)
click to toggle source
# File lib/email_parser/validator.rb, line 19 def validate_each(record, attribute, value) if value.nil? return if options[:allow_nil] record.errors.add(attribute, :blank) return end return if @parser.valid?(value) record.errors.add(attribute, :invalid) end