def norm.kind

cswap-bend-cli@0.1.0.0 · setload.bend:97

import cswap-bend-cli@0.1.0.0/setload.bend as Setload
import Base
import cswap-bend-cli@0.1.0.0/json.bend as Json
import cswap-bend-cli@0.1.0.0/settings.bend as Settings

97# One setting's lenient value: clamped into range, or the default for a value
98# of the wrong type.
99def norm.kind(kind: Settings.Sort, lo: String, hi: String, choices: String, dflt: Json.Json, v: Json.Json) -> Json.Json:
100  match kind:
101    case Settings.KFloat{}:
102      norm.numv(False{}, lo, hi, dflt, v)
103    case Settings.KInt{}:
104      norm.numv(True{}, lo, hi, dflt, v)
105    case Settings.KBool{}:
106      Json.JBool{truthy(v)}
107    case Settings.KChoice{}:
108      norm.choice(choices, dflt, v)
109    case Settings.KString{}:
110      norm.str(dflt, v)

Uses (8)

Used by (1)