Validates input based on delegate.
Input whitelist check.
FileSystem validator.
Validation error.
Specified expected entry type for FileSystemValidator.
Helper function to require passing a path pointing to existing directory.
Helper function to require passing a path pointing to existing file.
Helper function to require passing a path pointing to existing file or directory.
Helper function to define allowed values for an option or argument.
Helper function to add custom validating delegate.
Helper function to add custom validating delegate.
Helper function to add custom validating delegate.
Interface for validators.
User input validation.
This module contains core functionality for veryfing values as well as some basic validators.
Options and arguments (no flags, as they cannot take value) can have any number of validators attached. Validators are objects that verify user input after parsing values - every validator is run once per option/argument that it is attached to with complete vector of user input (e.g. for repeating values).
Validators are ran in order they are defined aborting on first failure with ValidationException. Exception contains the validator that caused the exception (optionally) along with error message.
Validators can be attached using validate method, or using helper methods in form of accepts*:
Custom Validators
To add custom validating logic, you can either create custom Validator class that implements IValidator interface or use DelegateValidator passing delegate with your validating logic:
Validators already provided: - EnumValidator (acceptsValues) - FileSystemValidator (acceptsFiles, acceptsDirectories) - DelegateValidator (validateWith, validateEachWith)