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

Method parsePositiveNonZeroFloat

options/parser/parse.go:97–115  ·  view source on GitHub ↗

parsePositiveNonZeroFloat parses a positive non-zero float64 option value

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

Source from the content-addressed store, hash-verified

95
96// parsePositiveNonZeroFloat parses a positive non-zero float64 option value
97func (p *Parser) parsePositiveNonZeroFloat(
98 ctx context.Context,
99 o *options.Options,
100 key string,
101 args ...string,
102) error {
103 if err := p.ensureMaxArgs(ctx, key, args, 1); err != nil {
104 return err
105 }
106
107 f, err := strconv.ParseFloat(args[0], 64)
108 if err != nil || f <= 0 {
109 return newInvalidArgumentError(ctx, key, args[0], "positive number")
110 }
111
112 o.Set(key, f)
113
114 return nil
115}
116
117// parseInt parses a positive integer option value
118func (p *Parser) parseInt(

Callers 3

applyZoomOptionMethod · 0.95
applyDprOptionMethod · 0.95
applyWatermarkOptionMethod · 0.95

Calls 3

ensureMaxArgsMethod · 0.95
newInvalidArgumentErrorFunction · 0.85
SetMethod · 0.45

Tested by

no test coverage detected