Class: Aequitas::Rule::Format::Proc

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

Constant Summary

Constants inherited from Aequitas::Rule::Format

EMAIL_ADDRESS, FORMATS, FORMAT_MESSAGES, URL

Instance Attribute Summary

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

#initialize, rules_for, #violation_type

Methods inherited from Aequitas::Rule

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

Methods included from ValueObject

#equalize_on

Constructor Details

This class inherits a constructor from Aequitas::Rule::Format

Instance Method Details

#valid?(resource) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
17
# File 'lib/aequitas/rule/format/proc.rb', line 10

def valid?(resource)
  value = attribute_value(resource)

  skip?(value) || format.call(value)
# rescue ::Encoding::CompatibilityError
#   # This is to work around a bug in jruby - see formats/email.rb
#   false
end