knuu icon indicating copy to clipboard operation
knuu copied to clipboard

It could be as simple as regex (from ChatGPT :) ):

Open smuu opened this issue 1 year ago • 0 comments

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

smuu avatar Apr 10 '24 11:04 smuu