2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-01-16 15:07:18 -05:00
|
|
|
class RegexPresenceValidator
|
|
|
|
include RegexSettingValidation
|
|
|
|
|
|
|
|
def initialize(opts = {})
|
|
|
|
@opts = opts
|
|
|
|
initialize_regex_opts(opts)
|
|
|
|
end
|
|
|
|
|
|
|
|
def valid_value?(val)
|
|
|
|
val.present? && regex_match?(val)
|
|
|
|
end
|
|
|
|
|
|
|
|
def error_message
|
|
|
|
I18n.t(@regex_error)
|
|
|
|
end
|
|
|
|
end
|