awslabs / goformation

GoFormation is a Go library for working with CloudFormation templates.
Apache License 2.0
841 stars 197 forks source link

MinValue and MaxValue from a parsed parameter are ambiguous #542

Closed rclark closed 9 months ago

rclark commented 1 year ago

I'm trying to parse a template parameter in order to provide a user with a prompt on the command line. Once they've entered a value, I would like to validate that it is appropriate. If the parameter type is "Number", then I would need to check:

  1. that the user entered a numeric value, and
  2. if the template file defined a MinValue and/or MaxValue for the parameter,
  3. then the user's numeric value falls between the defined min/max.

https://github.com/awslabs/goformation/blob/bf80608c482dde15129c70dd7175c74f143fd5bf/cloudformation/template.go#L36-L37

These fields are float64, which means that even if the optional properties are not present in the template file, the fields will get a zero-value of 0.

So the trouble is, I can't differentiate between a parameter where there is no defined MinValue, or a parameter where there is a defined MinValue of 0.

rclark commented 1 year ago

https://github.com/awslabs/goformation/blob/bf80608c482dde15129c70dd7175c74f143fd5bf/cloudformation/template.go#L34-L35

The same problem exists for validating the length of a "String" or "List" type of parameter.

rubenfonseca commented 1 year ago

Hi @rclark, looking at this now.

xrn commented 9 months ago

This can be closed