Class: ParsleySimpleForm::Constraints::Basics::MaxConstraint

Inherits:
ParsleySimpleForm::Constraints::BaseConstraint show all
Includes:
ParsleySimpleForm::Concerns::TypeSensitiveConcern
Defined in:
lib/parsley_simple_form/constraints/basics/max_constraint.rb

Constant Summary

Constants included from ParsleySimpleForm::Concerns::TypeSensitiveConcern

ParsleySimpleForm::Concerns::TypeSensitiveConcern::HTML_NATIVE_TYPES, ParsleySimpleForm::Concerns::TypeSensitiveConcern::TYPES_CONSTRAINTS, ParsleySimpleForm::Concerns::TypeSensitiveConcern::TYPE_MAP

Instance Method Summary collapse

Methods inherited from ParsleySimpleForm::Constraints::BaseConstraint

#initialize, #input_id, #input_type

Constructor Details

This class inherits a constructor from ParsleySimpleForm::Constraints::BaseConstraint

Instance Method Details

#html_attributesObject



14
15
16
17
18
# File 'lib/parsley_simple_form/constraints/basics/max_constraint.rb', line 14

def html_attributes
  attributes = {:'data-parsley-max-message' => I18n::translate('form_validation.message.max', max: @max)}
  attributes.merge!({:type => 'number', :max => @max}) if (@input_html[:max].nil? || !mapped_type.to_s == 'number')
  attributes
end

#match?Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
# File 'lib/parsley_simple_form/constraints/basics/max_constraint.rb', line 7

def match?
  return false if @options.nil?
  @input_html = @options[:input_html]
  @max = @options[:max] || @input_html[:max]
  !@options[:max].nil? || (!@input_html[:max].nil? && mapped_type.to_s == 'number')
end