Class: Beecart::Validators::BaseValidator

Inherits:
Object
  • Object
show all
Includes:
Beecart::Validator
Defined in:
lib/beecart/validators/base_validator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Beecart::Validator

included

Constructor Details

#initializeBaseValidator

Returns a new instance of BaseValidator.



11
12
13
14
15
# File 'lib/beecart/validators/base_validator.rb', line 11

def initialize
  @valid       = true
  @target_data = nil
  @errors      = {}
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



9
10
11
# File 'lib/beecart/validators/base_validator.rb', line 9

def error
  @error
end

#messagesObject (readonly)

Returns the value of attribute messages.



9
10
11
# File 'lib/beecart/validators/base_validator.rb', line 9

def messages
  @messages
end

Instance Method Details

#run(args) ⇒ Boolean

Run the validation for given data

Parameters:

  • data (Hash)

    Data that should be validated

Returns:

  • (Boolean)

    Result of Validation[:w



21
22
23
24
# File 'lib/beecart/validators/base_validator.rb', line 21

def run args
  @target_data = args
  @valid
end