Class: Rosette::Core::Validators::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/rosette/core/validators/validator.rb

Overview

Base class for validators.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Validator

Creates a new validator.

Parameters:

  • options (Hash) (defaults to: {})

    A hash of options.


17
18
19
# File 'lib/rosette/core/validators/validator.rb', line 17

def initialize(options = {})
  @options = options
end

Instance Attribute Details

#optionsHash (readonly)

Returns a hash of options.

Returns:

  • (Hash)

    a hash of options.


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rosette/core/validators/validator.rb', line 11

class Validator
  attr_reader :options

  # Creates a new validator.
  #
  # @param [Hash] options A hash of options.
  def initialize(options = {})
    @options = options
  end

  # An array of error messages. Populated when +#valid?+ is called.
  #
  # @return [Array<String>] The list of error messages.
  def messages
    @messages ||= []
  end
end

Instance Method Details

#messagesArray<String>

An array of error messages. Populated when #valid? is called.

Returns:

  • (Array<String>)

    The list of error messages.


24
25
26
# File 'lib/rosette/core/validators/validator.rb', line 24

def messages
  @messages ||= []
end