Skip to content

Validation

🛠️ Tools · ⬅ Top


This is a new feature and is in progress.

validate

Validate a value by type

Usage

validate handler type name value

Validate a value by type

Types are case-insensitive:

Text and formats

  • EmptyString - (alias string?, any) - Any value at all
  • String - (no aliases) - Any non-empty string
  • EnvironmentVariable - (alias env) - A non-empty string which contains alphanumeric characters or the underscore and does not begin with a digit.
  • Secret - (no aliases) - A value which is security sensitive
  • Date - (no aliases) - A valid date in the form YYYY-MM-DD
  • URL - (no aliases) - A Universal Resource Locator in the form scheme://user:password@host:port/path

Numbers

  • Flag - (no aliases) - Presence of an option to enables a feature. (e.g. --debug is a flag)
  • Boolean - (alias bool) - A value true or false
  • BooleanLike - (aliases boolean?, bool?) - A value which should be evaluated to a boolean value
  • Integer - (alias int) - Any integer, positive or negative
  • UnsignedInteger - (aliases uint, unsigned) - Any integer 0 or greater
  • PositiveInteger - (alias positive) - Any integer 1 or greater
  • Number - (alias number) - Any integer or real number

File system

  • Exists - (no aliases - A file (or directory) which exists in the file system of any type
  • File - (no aliases) - A file which exists in the file system which is not any special type
  • Link - (no aliases) - A link which exists in the file system
  • Directory - (alias dir) - A directory which exists in the file system
  • DirectoryList - (alias dirlist) - One or more directories as arguments
  • FileDirectory - (alias parent) - A file whose directory exists in the file system but which may or may not exist.
  • RealDirectory - (alias realdir) - The real path of a directory which must exist.
  • RealFile - (alias real) - The real path of a file which must exist.
  • RemoteDirectory - (alias remotedir) - The path to a directory on a remote host.

Application-relative

  • ApplicationDirectory - (alias appdir) - A directory path relative to BUILD_HOME
  • ApplicationFile - (alias appfile) - A file path relative to BUILD_HOME
  • ApplicationDirectoryList - (alias appdirlist) - One or more arguments of type ApplicationDirectory

Functional

  • Function - (alias function) - A defined function
  • Callable - (alias callable) - A function or executable
  • Executable - (alias bin) - Any binary available within the PATH

Lists

  • Array - (no aliases) - Zero or more arguments
  • List - (no aliases) - Zero or more arguments
  • ColonDelimitedList - (alias list:) - A colon-delimited list :
  • CommaDelimitedList - (alias list,) - A comma-delimited list ,

You can repeat the type name value more than once in the arguments and each will be checked until one fails Return Code: 0 - Valid is valid, stdout is a filtered version of the value to be used Return Code: 2 - Valid is invalid, output reason to stderr

Arguments

  • handler - Function. Required. Error handler.
  • type - Type. Required. Type to validate.
  • name - String. Required. Name of the variable which is being validated.
  • value - EmptyString. Required. Value to validate.

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

validateTypeList

List types which can be validated

Usage

validateTypeList

List types which can be validated

Arguments

  • none

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

isValidateType

Are all arguments passed a valid validate type?

Usage

isValidateType [ --help ] [ type ]

Are all arguments passed a valid validate type?

Arguments

  • --help - Optional. Flag. Display this help.
  • type - String. Optional. Type to validate as validate type.

Examples

isValidateType string || returnMessage 1 "string is not a type."

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error