Class: Ea::Validation::GridReferenceValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- Ea::Validation::GridReferenceValidator
- Defined in:
- lib/ea/validation/grid_reference_validator.rb
Instance Attribute Summary collapse
-
#allow_blank ⇒ Object
readonly
Returns the value of attribute allow_blank.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(options) ⇒ GridReferenceValidator
constructor
A new instance of GridReferenceValidator.
- #validate_each(record, attribute, value) ⇒ Object
Constructor Details
#initialize(options) ⇒ GridReferenceValidator
Returns a new instance of GridReferenceValidator.
8 9 10 11 12 |
# File 'lib/ea/validation/grid_reference_validator.rb', line 8 def initialize() @message = [:message] @allow_blank = [:allow_blank] super end |
Instance Attribute Details
#allow_blank ⇒ Object (readonly)
Returns the value of attribute allow_blank.
7 8 9 |
# File 'lib/ea/validation/grid_reference_validator.rb', line 7 def allow_blank @allow_blank end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
7 8 9 |
# File 'lib/ea/validation/grid_reference_validator.rb', line 7 def @message end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
7 8 9 |
# File 'lib/ea/validation/grid_reference_validator.rb', line 7 def value @value end |
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/ea/validation/grid_reference_validator.rb', line 14 def validate_each(record, attribute, value) @value = value return true if allow_blank && value.blank? return true unless os_map_ref_detects_error? || invalid_pattern? record.errors.add attribute, end |