check

inline fun <AllT : Any, ValueT> ProcessedArgument<AllT, ValueT>.check(message: String, crossinline validator: (AllT) -> 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.

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 : Any, ValueT> ProcessedArgument<AllT, ValueT>.check(crossinline lazyMessage: (AllT) -> String = { it.toString() }, crossinline validator: (AllT) -> 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 the returns a message to include in the error output.

You can use validate for more complex checks.

Example:

val arg by argument().int().check(lazyMessage={"$it is not even"}) { it % 2 == 0 }
@JvmName(name = nullableCheck)
inline fun <AllT : Any, ValueT> ProcessedArgument<AllT?, ValueT>.check(message: String, crossinline validator: (AllT) -> 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 }
@JvmName(name = nullableLazyCheck)
inline fun <AllT : Any, ValueT> ProcessedArgument<AllT?, ValueT>.check(crossinline lazyMessage: (AllT) -> String = { it.toString() }, crossinline validator: (AllT) -> 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 the 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 }