validate

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. The validator is not called if the delegate value is null.

Your validator can also call require to fail automatically if an expression is false, or message to show the user a warning message without aborting.

Example:

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