Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(api)!: Error instead of returning 0 on invalid inputs to conv.* functions #2104

Merged
merged 1 commit into from
Jun 16, 2024

Conversation

hairyhenderson
Copy link
Owner

This is a breaking change, but will result in more correct rendering.

Instead of quietly returning 0, a number of functions in the conv namespace will now return an error if the input is invalid.

This includes:

  • conv.ToInt64, conv.ToInt, conv.ToInt64s, conv.ToInts, conv.ToFloat64, conv.ToFloat64s, conv.ParseInt, conv.ParseFloat, conv.ParseUint, conv.Atoi

Because these functions are used by some other functions, this introduces stricter input validation for these functions:

  • coll.Flatten
  • crypto.PBKDF2, crypto.Bcrypt, crypto.RSAGenerateKey, crypto.EncryptAES, crypto.DecryptAES, crypto.DecryptAESBytes
  • math.Abs, math.Add, math.Mul, math.Sub, math.Div, math.Rem, math.Pow, math.Seq, math.Max, math.Min, math.Ceil, math.Floor, math.Round
  • net.CIDRHost, net.CIDRSubnets, net.CIDRSubnetSizes
  • random.ASCII, random.Alpha, random.AlphaNum, random.String, random.Number, random.Float
  • regexp.FindAll, regexp.Split
  • strings.Abbrev, strings.WordWrap
  • time.Nanosecond, time.Microsecond, time.Millisecond, time.Second, time.Minute, time.Hour

conv/conv.go Fixed Show fixed Hide fixed
@hairyhenderson hairyhenderson force-pushed the error-on-conv-to-functions branch 7 times, most recently from 6d205d8 to 46f874a Compare June 16, 2024 12:18
@hairyhenderson hairyhenderson force-pushed the error-on-conv-to-functions branch from 46f874a to a11e68e Compare June 16, 2024 19:08
@hairyhenderson hairyhenderson enabled auto-merge (squash) June 16, 2024 19:08
@hairyhenderson hairyhenderson merged commit c275254 into main Jun 16, 2024
15 checks passed
@hairyhenderson hairyhenderson deleted the error-on-conv-to-functions branch June 16, 2024 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant