firstValidatingFrom

fun <F, T> ConvertsTo<F, T>.firstValidatingFrom(validate: (F) -> Unit): ConvertsTo<F, T>

Adds validation before a conversion by running validate on F values before converting them to type T. Validators are expected to throw an exception if the expected condition is not met.

Parameters

F

The type being converted from

T

The type being converted to

validate

A function which accepts an F value and throws an exception if the expected condition is not met