Class: ParsleySimpleForm::Constraints::Basics::RegexpConstraint

Inherits:
ParsleySimpleForm::Constraints::BaseConstraint show all
Defined in:
lib/parsley_simple_form/constraints/basics/regexp_constraint.rb

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



16
17
18
19
# File 'lib/parsley_simple_form/constraints/basics/regexp_constraint.rb', line 16

def html_attributes
  {:'data-parsley-regexp-message' => I18n::translate('form_validation.message.regexp'),
    :pattern => @regexp}
end

#match?Boolean

Returns:

  • (Boolean)


5
6
7
8
9
10
11
12
13
14
# File 'lib/parsley_simple_form/constraints/basics/regexp_constraint.rb', line 5

def match?
  return false if @options.nil?
  
  if @options[:regexp].nil?
    @regexp = @options[:input_html][:regexp] unless @options[:input_html].nil?
  else
    @regexp = @options[:regexp]
  end
  !@regexp.nil?
end