Class: Rentlinx::BaseValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/rentlinx/validators/base_validator.rb

Overview

This is the base validator. It encapsulates all the logic shared between the various validators.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(val) ⇒ BaseValidator

Creates a new instance of the class, and validates but BaseValidator should never be directly instantiated.



9
10
11
12
13
# File 'lib/rentlinx/validators/base_validator.rb', line 9

def initialize(val)
  @value = val
  @error = ''
  validate
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



5
6
7
# File 'lib/rentlinx/validators/base_validator.rb', line 5

def error
  @error
end

Instance Method Details

#processed_valueObject

The processed value after validation of the attribute.

Returns:

  • a processed value, a stripped phone number for example



25
26
27
# File 'lib/rentlinx/validators/base_validator.rb', line 25

def processed_value
  @value
end

#valid?Boolean

Determines the validity of the attribute.

Returns:

  • (Boolean)

    true if valid, false if invalid



18
19
20
# File 'lib/rentlinx/validators/base_validator.rb', line 18

def valid?
  @error == ''
end