Module: RegexSettingValidation
- Included in:
- RegexPresenceValidator, StringSettingValidator, UsernameSettingValidator
- Defined in:
- lib/validators/regex_setting_validation.rb
Instance Method Summary collapse
Instance Method Details
#initialize_regex_opts(opts = {}) ⇒ Object
4 5 6 7 |
# File 'lib/validators/regex_setting_validation.rb', line 4 def initialize_regex_opts(opts = {}) @regex = Regexp.new(opts[:regex]) if opts[:regex] @regex_error = opts[:regex_error] || "site_settings.errors.regex_mismatch" end |
#regex_match?(val) ⇒ Boolean
9 10 11 12 13 14 15 16 |
# File 'lib/validators/regex_setting_validation.rb', line 9 def regex_match?(val) if @regex && !(val =~ @regex) @regex_fail = true return false end true end |