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

URI

class URI

JVM only

URI constrains String to be validated by java.net.URI

Safe nullable construction

import arrow.refinement.network.URI

URI.orNull("urn:isbn:0-476-27557-4")
// urn:isbn:0-476-27557-4
URI.orNull("not-uri")
// not-uri

Resolved constraints

URI.constraints("urn:isbn:0-476-27557-4")
// [(true, Expected urn:isbn:0-476-27557-4 to be a valid URI)]
URI.constraints("not-uri")
// [(true, Expected not-uri to be a valid URI)]
URI.isValid("urn:isbn:0-476-27557-4")
// true
URI.isValid("not-uri")
// true

Folding validation

URI.fold("urn:isbn:0-476-27557-4", { "failed: $it" }, { "success: $it" })
// success: URI(value=urn:isbn:0-476-27557-4)
URI.fold("not-uri", { "failed: $it" }, { "success: $it" })
// success: URI(value=not-uri)

Unsafe require

URI.require("urn:isbn:0-476-27557-4")
// urn:isbn:0-476-27557-4
try { URI.require("not-uri") } catch (e: IllegalArgumentException) { e.message }
// URI(value=not-uri)

Types

Companion companion object Companion : Refined<String, URI>

Properties

value val value: String

Do you like Arrow?

Arrow Org
<