Skip to content

crejk/pesel-parser

Repository files navigation

pesel-parser

Codacy Badge

PESEL

usage

val parser = PeselParser()
val result = parser.parse("64092555585"): PeselResult -> Validation<PeselParseFailure, Pesel>

result.fold<T>({ error ->
    error.description
}, { pesel ->
    pesel.toString()
}): String

result.getOrElseGet { throw RuntimeException(it.description()) }: Pesel
result.toOption(): Option<Pesel>
result.orNull(): Pesel?
result.get(): Pesel // if invalid throw NoSuchElementException