Module: Saphyr::Asserts::SizeAssert Private
- Included in:
- Fields::FieldBase
- Defined in:
- lib/saphyr/asserts/size_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
- #assert_size_len(opt_value, value, errors, error_code = Fields::FieldBase::ERR_SIZE_LEN) ⇒ Object private
- #assert_size_max(opt_value, value, errors, error_code = Fields::FieldBase::ERR_SIZE_MAX) ⇒ Object private
- #assert_size_min(opt_value, value, errors, error_code = Fields::FieldBase::ERR_SIZE_MIN) ⇒ Object private
Instance Method Details
#assert_size_len(opt_value, value, errors, error_code = Fields::FieldBase::ERR_SIZE_LEN) ⇒ 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 19 |
# File 'lib/saphyr/asserts/size_assert.rb', line 5 def assert_size_len opt_value, value, errors, error_code=Fields::FieldBase::ERR_SIZE_LEN return nil if opt_value.nil? unless value.size == opt_value errors << { type: err(error_code), data: { _val: value, len: opt_value, got: value.size, } } return false end true end |
#assert_size_max(opt_value, value, errors, error_code = Fields::FieldBase::ERR_SIZE_MAX) ⇒ 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.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/saphyr/asserts/size_assert.rb', line 37 def assert_size_max opt_value, value, errors, error_code=Fields::FieldBase::ERR_SIZE_MAX return nil if opt_value.nil? if value.size > opt_value errors << { type: err(error_code), data: { _val: value, max: opt_value, got: value.size, } } return false end true end |
#assert_size_min(opt_value, value, errors, error_code = Fields::FieldBase::ERR_SIZE_MIN) ⇒ 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.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/saphyr/asserts/size_assert.rb', line 21 def assert_size_min opt_value, value, errors, error_code=Fields::FieldBase::ERR_SIZE_MIN return nil if opt_value.nil? if value.size < opt_value errors << { type: err(error_code), data: { _val: value, min: opt_value, got: value.size, } } return false end true end |