Module: Saphyr::Asserts::StringAssert Private

Included in:
Fields::FieldBase
Defined in:
lib/saphyr/asserts/string_assert.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#assert_string_regexp(opt_value, value, errors, error_code = Fields::FieldBase::ERR_REGEXP) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/saphyr/asserts/string_assert.rb', line 5

def assert_string_regexp opt_value, value, errors, error_code=Fields::FieldBase::ERR_REGEXP
  return nil if opt_value.nil?
  unless value =~ opt_value
    errors << {
      type: err(error_code),
      data: {
        _val: value,
        regexp: opt_value,
      }
    }
    return false
  end
  true
end