shape

in gems/aws-sdk-core/lib/aws-sdk-core/param_validator.rb [152:200]


    def shape(ref, value, errors, context)
      case ref.shape
      when StructureShape then structure(ref, value, errors, context)
      when ListShape then list(ref, value, errors, context)
      when MapShape then map(ref, value, errors, context)
      when DocumentShape then document(ref, value, errors, context)
      when StringShape
        unless value.is_a?(String)
          errors << expected_got(context, "a String", value)
        end
      when IntegerShape
        unless value.is_a?(Integer)
          errors << expected_got(context, "an Integer", value)
        end
      when FloatShape
        unless value.is_a?(Float)
          errors << expected_got(context, "a Float", value)
        end
      when TimestampShape
        unless value.is_a?(Time)
          errors << expected_got(context, "a Time object", value)
        end
      when BooleanShape
        unless [true, false].include?(value)
          errors << expected_got(context, "true or false", value)
        end
      when BlobShape
        unless value.is_a?(String)
          if streaming_input?(ref)
            unless io_like?(value, _require_size = false)
              errors << expected_got(
                context,
                "a String or IO like object that supports read and rewind",
                value
              )
            end
          elsif !io_like?(value, _require_size = true)
            errors << expected_got(
              context,
              "a String or IO like object that supports read, rewind, and size",
              value
            )
          end
        end
      else
        raise "unhandled shape type: #{ref.shape.class.name}"
      end
    end