Class: SmartCore::Types::Primitive::NilableValidator Private
- Inherits:
-
Object
- Object
- SmartCore::Types::Primitive::NilableValidator
- Defined in:
- lib/smart_core/types/primitive/nilable_validator.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.
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
- #___assign_type___(type) ⇒ void private
-
#initialize(validator) ⇒ void
constructor
private
].
- #valid?(value) ⇒ Boolean private
- #validate(value) ⇒ SmartCore::Types::Primitive::Validator::Result, ... private
- #validate!(value) ⇒ void private
Constructor Details
#initialize(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.
]
18 19 20 21 |
# File 'lib/smart_core/types/primitive/nilable_validator.rb', line 18 def initialize(validator) @type = nil @validator = validator end |
Instance Method Details
#___assign_type___(type) ⇒ 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.
28 29 30 |
# File 'lib/smart_core/types/primitive/nilable_validator.rb', line 28 def ___assign_type___(type) @type = type end |
#valid?(value) ⇒ Boolean
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.
36 37 38 |
# File 'lib/smart_core/types/primitive/nilable_validator.rb', line 36 def valid?(value) (value == nil) ? true : validator.valid?(value) end |
#validate(value) ⇒ SmartCore::Types::Primitive::Validator::Result, ...
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.
48 49 50 51 |
# File 'lib/smart_core/types/primitive/nilable_validator.rb', line 48 def validate(value) return Result.new(type, value) if value == nil validator.validate(value) end |
#validate!(value) ⇒ 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.
60 61 62 63 |
# File 'lib/smart_core/types/primitive/nilable_validator.rb', line 60 def validate!(value) return if valid?(value) raise(SmartCore::Types::TypeError, 'Invalid type') end |