Class: Aequitas::Rule::Length::Minimum
- Inherits:
-
Aequitas::Rule::Length
- Object
- Aequitas::Rule
- Aequitas::Rule::Length
- Aequitas::Rule::Length::Minimum
- Defined in:
- lib/aequitas/rule/length/minimum.rb
Instance Attribute Summary collapse
-
#bound ⇒ Object
readonly
Returns the value of attribute bound.
Attributes inherited from Aequitas::Rule
#attribute_name, #custom_message, #guard, #skip_condition
Attributes included from ValueObject
Instance Method Summary collapse
-
#initialize(attribute_name, options) ⇒ Minimum
constructor
A new instance of Minimum.
-
#valid_length?(length) ⇒ String, NilClass
private
Validate the value length is greater than or equal to the bound.
- #violation_data(resource) ⇒ Object
- #violation_type(resource) ⇒ Object
Methods inherited from Aequitas::Rule::Length
rules_for, #valid?, #value_length
Methods inherited from Aequitas::Rule
#attribute_value, #execute?, rules_for, #skip?, #validate, #violation_info, #violation_values
Methods included from ValueObject
Constructor Details
#initialize(attribute_name, options) ⇒ Minimum
Returns a new instance of Minimum.
14 15 16 17 18 |
# File 'lib/aequitas/rule/length/minimum.rb', line 14 def initialize(attribute_name, ) super @bound = .fetch(:bound) end |
Instance Attribute Details
#bound ⇒ Object (readonly)
Returns the value of attribute bound.
12 13 14 |
# File 'lib/aequitas/rule/length/minimum.rb', line 12 def bound @bound end |
Instance Method Details
#valid_length?(length) ⇒ String, NilClass
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.
Validate the value length is greater than or equal to the bound
37 38 39 |
# File 'lib/aequitas/rule/length/minimum.rb', line 37 def valid_length?(length) bound <= length end |
#violation_data(resource) ⇒ Object
24 25 26 |
# File 'lib/aequitas/rule/length/minimum.rb', line 24 def violation_data(resource) [ [ :minimum, bound ] ] end |
#violation_type(resource) ⇒ Object
20 21 22 |
# File 'lib/aequitas/rule/length/minimum.rb', line 20 def violation_type(resource) :too_short end |