FuncType - v0.8.85
    Preparing search index...

    Function BoundedNumber

    • Create a number brand with min/max bounds

      Parameters

      • brand: string
      • min: number
      • max: number

      Returns ValidatedBrand<string, number>

      const Percentage = BoundedNumber("Percentage", 0, 100)
      const valid = Percentage.of(75) // Some(Brand<"Percentage", number>)
      const invalid = Percentage.of(150) // None
      const Port = BoundedNumber("Port", 1, 65535)
      const httpPort = Port.unsafeOf(80) // Brand<"Port", number>
      // Port.unsafeOf(70000) // throws Error