Class: SmartCore::Validator::Commands::ValidateWith Private

Inherits:
Base
  • Object
show all
Includes:
WorkWithNestedsMixin
Defined in:
lib/smart_core/validator/commands/validate_with.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from WorkWithNestedsMixin

#build_nested_validator, #build_sub_validator, #check_nested_validations

Constructor Details

#initialize(validating_klass, nested_validations) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

Since:

  • 0.1.0



28
29
30
31
# File 'lib/smart_core/validator/commands/validate_with.rb', line 28

def initialize(validating_klass, nested_validations)
  @validating_klass = validating_klass
  @nested_validations = nested_validations
end

Instance Attribute Details

#nested_validationsProc (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Proc)

Since:

  • 0.1.0



20
21
22
# File 'lib/smart_core/validator/commands/validate_with.rb', line 20

def nested_validations
  @nested_validations
end

#validating_klassClass<SmartCore::Validator> (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

Since:

  • 0.1.0



14
15
16
# File 'lib/smart_core/validator/commands/validate_with.rb', line 14

def validating_klass
  @validating_klass
end

Instance Method Details

#call(validator) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Parameters:

Since:

  • 0.1.0



38
39
40
41
42
43
44
45
46
# File 'lib/smart_core/validator/commands/validate_with.rb', line 38

def call(validator)
  sub_validator = build_sub_validator(validator, validating_klass)

  if sub_validator.valid?
    check_nested_validations(validator, nested_validations)
  else
    validator.__append_errors__(sub_validator.__validation_errors__)
  end
end