validatingTo

fun <F, T> Converter<F, T>.validatingTo(validate: (T) -> Unit): Converter<F, T>

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

Parameters

F

The type being converted to

T

The type being converted from

validate

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