Sha256: 524743f571ce6659b423cd01dc79bba7e389962de70a6f65ebaadb568e5c940f
Contents?: true
Size: 788 Bytes
Versions: 1
Compression:
Stored size: 788 Bytes
Contents
require "mountapi/schema/validator" module Mountapi module Request # Process request params against route parameters definition class ParamParser attr_reader :input, :definition def self.call(*args) new(*args).call end def initialize(input, definition) @input = input @definition = definition end def call validate end private # Remove unreferenced params def filter definition.filter(input) end def validate errors = Schema::Validator.call(definition.validation_schema, casted) errors.empty? && casted || raise(Error::InvalidParameter, errors) end def casted @casted = definition.cast(filter) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mountapi-0.11.1 | lib/mountapi/request/param_parser.rb |