Skip to content

Validation

zvozin edited this page Apr 13, 2017 · 2 revisions

An ad-hoc validation can be created the usual way:

    val invalid: Validation<Tuple2<Int, Int>, String> = invalid("your value sucks")
    val valid: Validation<Tuple2<Int, Int>, String> = valid(tuple(7, 11))

A Kotlin Iterable of Validations can be sequenced as follows:

    val validOfSeq: Validation<List<Int>, Seq<String>> = 
        listOf(valid(1), invalid("not one at all")).sequence()
Clone this wiki locally