Skip to main content

is_valid_quantity

Function is_valid_quantity 

Source
pub fn is_valid_quantity(s: &str) -> bool
Expand description

Validates a string against the Kubernetes quantity grammar.

Grammar: sign? digits (. digits?)? (exponent | suffix)?

  • DecimalSI suffixes: n, u, m, k, M, G, T, P, E
  • BinarySI suffixes: Ki, Mi, Gi, Ti, Pi, Ei
  • Exponent: e/E followed by optional sign and digits

Disambiguation: "1E" is suffix Exa, not an incomplete exponent.