MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / parsePositiveInt

Method parsePositiveInt

options/parser/parse.go:160–178  ·  view source on GitHub ↗

parsePositiveInt parses a positive integer option value

(
	ctx context.Context,
	o *options.Options,
	key string,
	args ...string,
)

Source from the content-addressed store, hash-verified

158
159// parsePositiveInt parses a positive integer option value
160func (p *Parser) parsePositiveInt(
161 ctx context.Context,
162 o *options.Options,
163 key string,
164 args ...string,
165) error {
166 if err := p.ensureMaxArgs(ctx, key, args, 1); err != nil {
167 return err
168 }
169
170 i, err := strconv.Atoi(args[0])
171 if err != nil || i < 0 {
172 return newInvalidArgumentError(ctx, key, args[0], "positive number or 0")
173 }
174
175 o.Set(key, i)
176
177 return nil
178}
179
180// parseQualityInt parses a quality integer option value (minQ-100)
181func (p *Parser) parseQualityInt(

Callers 7

applyWidthOptionMethod · 0.95
applyHeightOptionMethod · 0.95
applyMinWidthOptionMethod · 0.95
applyMinHeightOptionMethod · 0.95
applyPaddingOptionMethod · 0.95
applyMaxBytesOptionMethod · 0.95
applyPixelateOptionMethod · 0.95

Calls 3

ensureMaxArgsMethod · 0.95
newInvalidArgumentErrorFunction · 0.85
SetMethod · 0.45

Tested by

no test coverage detected