Module: LimitsHelper
- Defined in:
- app/helpers/limits_helper.rb
Instance Method Summary collapse
- #validated_max(record, attr) ⇒ Integer, NilClass
- #validated_maxlength(record, attr) ⇒ Integer, NilClass
- #validated_min(record, attr) ⇒ Integer, NilClass
- #validated_minlength(record, attr) ⇒ Integer, NilClass
- #validated_required(record, attr) ⇒ Boolean
Instance Method Details
#validated_max(record, attr) ⇒ Integer, NilClass
41 42 43 |
# File 'app/helpers/limits_helper.rb', line 41 def validated_max(record, attr) validated_value(record: record, attr: attr, type: :numericality, options: [:less_than, :less_than_or_equal_to]) end |
#validated_maxlength(record, attr) ⇒ Integer, NilClass
13 14 15 16 17 |
# File 'app/helpers/limits_helper.rb', line 13 def validated_maxlength(record, attr) maximum = validated_value(record: record, attr: attr, type: :length, options: [:maximum]) range = validated_value(record: record, attr: attr, type: :length, options: [:in]) range&.max || maximum end |
#validated_min(record, attr) ⇒ Integer, NilClass
53 54 55 |
# File 'app/helpers/limits_helper.rb', line 53 def validated_min(record, attr) validated_value(record: record, attr: attr, type: :numericality, options: [:greater_than, :greater_than_or_equal_to]) end |
#validated_minlength(record, attr) ⇒ Integer, NilClass
27 28 29 30 31 |
# File 'app/helpers/limits_helper.rb', line 27 def validated_minlength(record, attr) minimum = validated_value(record: record, attr: attr, type: :length, options: [:minimum]) range = validated_value(record: record, attr: attr, type: :length, options: [:in]) range&.min || minimum end |
#validated_required(record, attr) ⇒ Boolean
65 66 67 68 |
# File 'app/helpers/limits_helper.rb', line 65 def validated_required(record, attr) # validated_value(record: record, attr: attr, type: :presence, options: [:presece]) ? validators_for(record: record, attr: attr, type: :presence).any? end |