def octet.lead
import bend-kit-netip@0.1.0.0/netip.bend as Netipimport Base
55# 1 to 3 characters, and no leading zero unless the octet is "0".
56def octet.lead(s: String) -> Bool:
57 match s:
58 case SNil{}:
59 False{}
60 case SCon{Chr{c}, +t}:
61 Bool.and(Nat.is_le(String.length(t), 2n), Bool.or(Bool.not(U32.is_eq(c, 48)), String.is_empty(t)))