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, #to_ast, #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, #optional?, #primitive?, #result, #success, #to_ast, #try
Methods included from Builder
#constrained, #constrained_type, #constructor, #default, #enum, #maybe, #optional, #safe, #|
Methods included from Options
#initialize, #meta, #pristine, #with
Constructor Details
This class inherits a constructor from Dry::Types::Hash::Schema
Instance Method Details
#hash_type ⇒ Object (private)
186 187 188 |
# File 'lib/dry/types/hash/schema.rb', line 186 def hash_type :strict_with_defaults end |
#resolve_missing_value(result, key, type) ⇒ Object (private)
196 197 198 199 200 201 202 |
# File 'lib/dry/types/hash/schema.rb', line 196 def resolve_missing_value(result, key, type) if type.default? result[key] = type.evaluate else super end end |