arrow-refined-types / arrow.refinement.chars / WhiteSpaceChar

WhiteSpaceChar

class WhiteSpaceChar

WhiteSpaceChar constrains Char to a white space char

Safe nullable construction

import arrow.refinement.chars.WhiteSpaceChar

WhiteSpaceChar.orNull(' ')
// WhiteSpaceChar(value= )
WhiteSpaceChar.orNull('a')

Resolved constraints

WhiteSpaceChar.constraints('A')
// [(false, Expected A to be white space)]
WhiteSpaceChar.constraints(' ')
// [(true, Expected   to be white space)]
WhiteSpaceChar.isValid(' ')
// true
WhiteSpaceChar.isValid('A')
// false

Folding validation

WhiteSpaceChar.fold('A', { "failed: $it" }, { "success: $it" })
// failed: [(false, Expected A to be white space)]
WhiteSpaceChar.fold(' ', { "failed: $it" }, { "success: $it" })
// success: WhiteSpaceChar(value= )

Unsafe require

WhiteSpaceChar.require(' ')
//  
try { WhiteSpaceChar.require('A') } catch (e: IllegalArgumentException) { e.message }
// Expected A to be white space

Types

Companion companion object Companion : Refined<Char, WhiteSpaceChar>

Properties

value val value: Char

Do you like Arrow?

Arrow Org
<