validateEachWith

Helper function to add custom validating delegate.

This function is meant to be used with UFCS, so that it can be placed within option definition chain.

This function automatically prepends entry information to your error message, so that call to new Option("", "foo", "").validateWith(a => a.isDir, "must be a directory") on failure would throw ValidationException with message option foo must be a directory.

  1. T validateEachWith(T entry, void delegate(IEntry, string) validator)
  2. T validateEachWith(T entry, bool delegate(string) validator, string errorMessage)
    T
    validateEachWith
    (
    T : IEntry
    )
    (
    ,
    bool delegate(
    string
    )
    validator
    ,
    )

Examples

new Program("rm")
    .add(new Argument("target", "target to remove")
        .validateEachWith(arg => arg.isSymLink, "must be a symlink")
    )

See Also

DelegateValidator, validateWith

Meta