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

Method parsePositiveFloat

options/parser/parse.go:76–94  ·  view source on GitHub ↗

parsePositiveFloat parses a positive float64 option value

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

Source from the content-addressed store, hash-verified

74
75// parsePositiveFloat parses a positive float64 option value
76func (p *Parser) parsePositiveFloat(
77 ctx context.Context,
78 o *options.Options,
79 key string,
80 args ...string,
81) error {
82 if err := p.ensureMaxArgs(ctx, key, args, 1); err != nil {
83 return err
84 }
85
86 f, err := strconv.ParseFloat(args[0], 64)
87 if err != nil || f < 0 {
88 return newInvalidArgumentError(ctx, key, args[0], "positive number or 0")
89 }
90
91 o.Set(key, f)
92
93 return nil
94}
95
96// parsePositiveNonZeroFloat parses a positive non-zero float64 option value
97func (p *Parser) parsePositiveNonZeroFloat(

Callers 3

applyCropOptionMethod · 0.95
applyBlurOptionMethod · 0.95
applySharpenOptionMethod · 0.95

Calls 3

ensureMaxArgsMethod · 0.95
newInvalidArgumentErrorFunction · 0.85
SetMethod · 0.45

Tested by

no test coverage detected