Class: UseCaseValidations::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/usecasing_validations/validator.rb

Direct Known Subclasses

CustomValidator, EachValidator

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Validator

Returns a new instance of Validator.



8
9
10
# File 'lib/usecasing_validations/validator.rb', line 8

def initialize(options = {})
  @options  = Helpers._except(options, :class).freeze
end

Instance Attribute Details

#baseObject

Returns the value of attribute base.



6
7
8
# File 'lib/usecasing_validations/validator.rb', line 6

def base
  @base
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/usecasing_validations/validator.rb', line 5

def options
  @options
end

Instance Method Details

#validate(record) ⇒ Object

Override this method in subclasses with validation logic, adding errors to the records errors array where necessary.

Raises:

  • (NotImplementedError)


14
15
16
# File 'lib/usecasing_validations/validator.rb', line 14

def validate(record)
  raise NotImplementedError, "Subclasses must implement a validate(record) method."
end