knuu
knuu copied to clipboard
It could be as simple as regex (from ChatGPT :) ):
It could be as simple as regex (from ChatGPT :) ):
func isValidVolumeSize(size string) bool {
// Regular expression pattern for validating volume sizes
pattern := `^\d+(Gi|Mi|Ki)?$`
// Compile the regular expression
re := regexp.MustCompile(pattern)
// Match the size against the pattern
return re.MatchString(size)
}
Or go for more complex like defining an enum and using it to contain the possible values
Originally posted by @rach-id in https://github.com/celestiaorg/celestia-app/issues/3287#issuecomment-2045612879