arrow-refined-types / arrow.refinement.strings / EndsWith

EndsWith

class EndsWith

EndsWith constrains String to end with Value

Safe nullable construction

import arrow.refinement.strings.EndsWith

EndsWith.Value("world").orNull("hello world")
// hello world
EndsWith.Value("world").orNull("abc")

Resolved constraints

EndsWith.Value("world").constraints("hello world")
// [(true, Expected hello world to end with world)]
EndsWith.Value("world").constraints("abc")
// [(false, Expected abc to end with world)]
EndsWith.Value("world").isValid("hello world")
// true
EndsWith.Value("world").isValid("abc")
// false

Folding validation

EndsWith.Value("world").fold("hello world", { "failed: $it" }, { "success: $it" })
// success: EndsWith(value=hello world)
EndsWith.Value("world").fold("abc", { "failed: $it" }, { "success: $it" })
// failed: [(false, Expected abc to end with world)]

Unsafe require

EndsWith.Value("world").require("hello world")
// hello world
try { EndsWith.Value("world").require("abc") } catch (e: IllegalArgumentException) { e.message }
// Expected abc to end with world

Types

Value class Value : Refined<String, EndsWith>

Properties

value val value: String

Do you like Arrow?

Arrow Org
<