Class: SmartCore::Types::Primitive::Validator::Result Private

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_core/types/primitive/validator/result.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.2.0

Constant Summary collapse

NO_INVARIANT_ERRORS =

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

Returns:

  • (Array)

Since:

  • 0.2.0

[].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, checked_value, is_valid_check, invariant_errors = NO_INVARIANT_ERRORS.dup) ⇒ 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:

  • type (SmartCore::Types::Primitive)
  • checked_value (Any)
  • is_valid_check (Boolean)
  • invariant_errors (Array<String>) (defaults to: NO_INVARIANT_ERRORS.dup)

Since:

  • 0.2.0



48
49
50
51
52
53
# File 'lib/smart_core/types/primitive/validator/result.rb', line 48

def initialize(type, checked_value, is_valid_check, invariant_errors = NO_INVARIANT_ERRORS.dup)
  @type = type
  @checked_value = checked_value
  @is_valid_check = is_valid_check
  @invariant_errors = invariant_errors.tap(&:freeze)
end

Instance Attribute Details

#checked_valueAny (readonly) Also known as: value

Returns:

  • (Any)

Since:

  • 0.2.0



29
30
31
# File 'lib/smart_core/types/primitive/validator/result.rb', line 29

def checked_value
  @checked_value
end

#invariant_errorsArray<String> (readonly) Also known as: errors, error_codes

Returns:

  • (Array<String>)

Since:

  • 0.2.0



36
37
38
# File 'lib/smart_core/types/primitive/validator/result.rb', line 36

def invariant_errors
  @invariant_errors
end

#is_valid_checkBoolean (readonly) Also known as: valid_check?

Returns:

  • (Boolean)

Since:

  • 0.2.0



22
23
24
# File 'lib/smart_core/types/primitive/validator/result.rb', line 22

def is_valid_check
  @is_valid_check
end

#typeSmartCore::Types::Primitive (readonly)

Returns:

Since:

  • 0.2.0



16
17
18
# File 'lib/smart_core/types/primitive/validator/result.rb', line 16

def type
  @type
end

Instance Method Details

#failure?Boolean

Returns:

  • (Boolean)

Since:

  • 0.2.0



75
76
77
# File 'lib/smart_core/types/primitive/validator/result.rb', line 75

def failure?
  !success?
end

#success?Boolean

Returns:

  • (Boolean)

Since:

  • 0.2.0



67
68
69
# File 'lib/smart_core/types/primitive/validator/result.rb', line 67

def success?
  valid_check? && invariant_errors.empty?
end

#valid_invariants?Boolean

Returns:

  • (Boolean)

Since:

  • 0.2.0



59
60
61
# File 'lib/smart_core/types/primitive/validator/result.rb', line 59

def valid_invariants?
  invariant_errors.empty?
end