Class: Dry::Types::Hash::StrictWithDefaults
- Inherits:
-
Strict
- Object
- Definition
- Dry::Types::Hash
- Schema
- Permissive
- Strict
- Dry::Types::Hash::StrictWithDefaults
- Includes:
- MaybeTypes
- Defined in:
- lib/dry/types/hash/schema.rb,
lib/dry/types/extensions/maybe.rb
Overview
StrictWithDefaults checks that there are no extra keys (raises UnknownKeysError otherwise) and there a no missing keys without default values given (raises MissingKeyError otherwise).
Instance Attribute Summary
Attributes inherited from Schema
Attributes inherited from Definition
Attributes included from Options
Instance Method Summary collapse
Methods inherited from Strict
Methods inherited from Schema
#call, #coerce, #initialize, #resolve, #try, #try_coerce
Methods inherited from Dry::Types::Hash
#permissive, #schema, #strict, #strict_with_defaults, #symbolized, #weak
Methods inherited from Definition
[], #call, #constrained?, #default?, #failure, #initialize, #name, #primitive?, #result, #success, #try
Methods included from Builder
#constrained, #constrained_type, #constructor, #default, #enum, #maybe, #optional, #safe, #|
Methods included from Options
Constructor Details
This class inherits a constructor from Dry::Types::Hash::Schema
Instance Method Details
#resolve_missing_value(result, key, type) ⇒ Object (private)
164 165 166 167 168 169 170 |
# File 'lib/dry/types/hash/schema.rb', line 164 def resolve_missing_value(result, key, type) if type.default? result[key] = type.evaluate else super end end |