check

inline fun <AllT, ValueT> ProcessedArgument<AllT, ValueT>.check(message: String, crossinline validator: (AllT & Any) -> Boolean): ArgumentDelegate<AllT>

Check the final argument value and raise an error if it's not valid.

The validator is called with the final argument type (the output of transformAll), and should return false if the value is not valid. You can specify a message to include in the error output. The validator is not called if the delegate value is null.

You can use validate for more complex checks.

Example:

val arg by argument().int().check("value must be even") { it % 2 == 0 }

inline fun <AllT, ValueT> ProcessedArgument<AllT, ValueT>.check(crossinline lazyMessage: (AllT & Any) -> String = { it.toString() }, crossinline validator: (AllT & Any) -> Boolean): ArgumentDelegate<AllT>

Check the final argument value and raise an error if it's not valid.

The validator is called with the final argument type (the output of transformAll), and should return false if the value is not valid. You can specify a lazyMessage that returns a message to include in the error output. The validator is not called if the delegate value is null.

You can use validate for more complex checks.

Example:

val arg by argument().int().check(lazyMessage={"$it is not even"}) { it % 2 == 0 }