Validation
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- (aliasstring?,any) - Any value at allString- (no aliases) - Any non-empty stringEnvironmentVariable- (aliasenv) - 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 sensitiveDate- (no aliases) - A valid date in the formYYYY-MM-DDURL- (no aliases) - A Universal Resource Locator in the formscheme://user:password@host:port/path
Numbers
Flag- (no aliases) - Presence of an option to enables a feature. (e.g.--debugis aflag)Boolean- (aliasbool) - A valuetrueorfalseBooleanLike- (aliasesboolean?,bool?) - A value which should be evaluated to a boolean valueInteger- (aliasint) - Any integer, positive or negativeUnsignedInteger- (aliasesuint,unsigned) - Any integer 0 or greaterPositiveInteger- (aliaspositive) - Any integer 1 or greaterNumber- (aliasnumber) - Any integer or real number
File system
Exists- (no aliases - A file (or directory) which exists in the file system of any typeFile- (no aliases) - A file which exists in the file system which is not any special typeLink- (no aliases) - A link which exists in the file systemDirectory- (aliasdir) - A directory which exists in the file systemDirectoryList- (aliasdirlist) - One or more directories as argumentsFileDirectory- (aliasparent) - A file whose directory exists in the file system but which may or may not exist.RealDirectory- (aliasrealdir) - The real path of a directory which must exist.RealFile- (aliasreal) - The real path of a file which must exist.RemoteDirectory- (aliasremotedir) - The path to a directory on a remote host.
Application-relative
ApplicationDirectory- (aliasappdir) - A directory path relative toBUILD_HOMEApplicationFile- (aliasappfile) - A file path relative toBUILD_HOMEApplicationDirectoryList- (aliasappdirlist) - One or more arguments of typeApplicationDirectory
Functional
Function- (aliasfunction) - A defined functionCallable- (aliascallable) - A function or executableExecutable- (aliasbin) - Any binary available within thePATH
Lists
Array- (no aliases) - Zero or more argumentsList- (no aliases) - Zero or more argumentsColonDelimitedList- (aliaslist:) - A colon-delimited list:CommaDelimitedList- (aliaslist,) - 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- Success1- Environment error2- Argument error
validateTypeList
List types which can be validated
Usage
validateTypeList
List types which can be validated
Arguments
- none
Return codes
0- Success1- Environment error2- 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 asvalidatetype.
Examples
isValidateType string || returnMessage 1 "string is not a type."
Return codes
0- Success1- Environment error2- Argument error