Class: ParsleySimpleForm::Constraints::Basics::MinConstraint

Inherits:
ParsleySimpleForm::Constraints::BaseConstraint show all
Includes:
ParsleySimpleForm::Concerns::TypeSensitiveConcern
Defined in:
lib/parsley_simple_form/constraints/basics/min_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



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

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

#match?Boolean

Returns:

  • (Boolean)


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

def match?
  return false if @options.nil?
  @min = @options[:min]

  @input_html = @options[:input_html]
  !@options[:min].nil? || (!@input_html[:min].nil? && mapped_type == 'number')
end