Class: Aequitas::Rule::Format::Regexp

Inherits:
Aequitas::Rule::Format show all
Defined in:
lib/aequitas/rule/format/regexp.rb

Constant Summary

Constant Summary

Constants inherited from Aequitas::Rule::Format

EMAIL_ADDRESS, FORMATS, FORMAT_MESSAGES, URL

Instance Attribute Summary collapse

Attributes inherited from Aequitas::Rule::Format

#format

Attributes inherited from Aequitas::Rule

#attribute_name, #custom_message, #guard, #skip_condition

Attributes included from ValueObject

#equalizer

Instance Method Summary collapse

Methods inherited from Aequitas::Rule::Format

rules_for, #valid_value?, #violation_type

Methods inherited from Aequitas::Rule

#attribute_value, #execute?, rules_for, #skip?, #validate, #violation_data, #violation_info, #violation_values

Methods included from ValueObject

#equalize_on

Constructor Details

#initialize(attribute_name, options = {}) ⇒ Regexp



14
15
16
17
18
# File 'lib/aequitas/rule/format/regexp.rb', line 14

def initialize(attribute_name, options = {})
  super

  @format_name = options.fetch(:format_name, nil)
end

Instance Attribute Details

#format_nameObject (readonly)

Returns the value of attribute format_name



12
13
14
# File 'lib/aequitas/rule/format/regexp.rb', line 12

def format_name
  @format_name
end

Instance Method Details

#expected_format?(value) ⇒ Boolean



20
21
22
# File 'lib/aequitas/rule/format/regexp.rb', line 20

def expected_format?(value)
  value ? value.to_s =~ self.format : false
end