clikt / com.github.ajalt.clikt.parameters.arguments / validate

validate

fun Any, ValueT> ProcessedArgument.validate(validator: ArgValidator): ArgumentDelegate

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 call fail if the value is not valid.

You can also call require to fail automatically if an expression is false.

Example:

``` kotlin val opt by argument().int().validate { require(it % 2 == 0) { “value must be even” } }