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

LowerCaseChar

class LowerCaseChar

LowerCaseChar constrains Char to a lowercase char

Safe nullable construction

import arrow.refinement.chars.LowerCaseChar

LowerCaseChar.orNull('A')
LowerCaseChar.orNull('a')
// LowerCaseChar(value=a)
LowerCaseChar.orNull('%')

Resolved constraints

LowerCaseChar.constraints('A')
// [(false, Expected A to be lower case)]
LowerCaseChar.constraints('a')
// [(true, Expected a to be lower case)]
LowerCaseChar.isValid('A')
// false
LowerCaseChar.isValid('a')
// true
LowerCaseChar.isValid('%')
// false

Folding validation

LowerCaseChar.fold('A', { "failed: $it" }, { "success: $it" })
// failed: [(false, Expected A to be lower case)]
LowerCaseChar.fold('a', { "failed: $it" }, { "success: $it" })
// success: LowerCaseChar(value=a)
LowerCaseChar.fold('%', { "failed: $it" }, { "success: $it" })
// failed: [(false, Expected % to be lower case)]

Unsafe require

LowerCaseChar.require('a')
// a
try { LowerCaseChar.require('A') } catch (e: IllegalArgumentException) { e.message }
// Expected A to be lower case

Types

Companion companion object Companion : Refined<Char, LowerCaseChar>

Properties

value val value: Char

Do you like Arrow?

Arrow Org
<