-
Notifications
You must be signed in to change notification settings - Fork 6
Params
Matt Muller edited this page Apr 10, 2024
·
6 revisions
Params are modules that convert user provided input into rigid shapes used by middleware. Params have a 1:1 mapping to Smithy shapes.
Param modules will initialize Types and set members if they exist. Params will do lightweight validation (using Hearth::Validator
) for aggregate structures, such as Array, Hash, and Set, so that values can be iterated over.
module HighScoreService
# @api private
module Params
class HighScoreParams
def self.build(params, context:)
Hearth::Validator.validate_types!(params, ::Hash, Types::HighScoreParams, context: context)
type = Types::HighScoreParams.new
Hearth::Validator.validate_unknown!(type, params, context: context) if params.is_a?(Hash)
type.game = params[:game]
type.score = params[:score]
type
end
end
end
end