arrow-refined-types / arrow.refinement.network / Rfc5737Testnet3Network

Rfc5737Testnet3Network

class Rfc5737Testnet3Network

Rfc5737Testnet3Network constrains String to be an IPv4 that StartsWith 203.0.113..

Safe nullable construction

import arrow.refinement.network.Rfc5737Testnet3Network

Rfc5737Testnet3Network.orNull("203.0.113.1")
// 203.0.113.1
Rfc5737Testnet3Network.orNull("80.34.200.60")

Resolved constraints

Rfc5737Testnet3Network.constraints("203.0.113.1")
// [(true, Expected 203.0.113.1 to be an IPv4 address), (true, Expected 203.0.113.1 to start with 203.0.113.)]
Rfc5737Testnet3Network.constraints("80.34.200.60")
// [(true, Expected 80.34.200.60 to be an IPv4 address), (false, Expected 80.34.200.60 to start with 203.0.113.)]
Rfc5737Testnet3Network.isValid("203.0.113.1")
// true
Rfc5737Testnet3Network.isValid("80.34.200.60")
// false

Folding validation

Rfc5737Testnet3Network.fold("203.0.113.1", { "failed: $it" }, { "success: $it" })
// success: Rfc5737Testnet3Network(value=203.0.113.1)
Rfc5737Testnet3Network.fold("80.34.200.60", { "failed: $it" }, { "success: $it" })
// failed: [(false, Expected 80.34.200.60 to start with 203.0.113.)]

Unsafe require

try { Rfc5737Testnet3Network.require("80.34.200.60") } catch (e: IllegalArgumentException) { e.message }
// Expected 80.34.200.60 to start with 203.0.113.
Rfc5737Testnet3Network.require("203.0.113.1")
// 203.0.113.1

Types

Companion companion object Companion : Refined<String, Rfc5737Testnet3Network>

Properties

value val value: String

Do you like Arrow?

Arrow Org
<