Class: ValidationUtils
Defined in: core/src/ValidationUtils.ts:15
A collection of validation functions to use with the @Validator() decorator.
Constructors
Constructor
new ValidationUtils():
ValidationUtils
Returns
ValidationUtils
Methods
check()
staticcheck(val,func):any
Defined in: core/src/ValidationUtils.ts:24
A simple wrapper that calls the specified boolean validation function with the given value and returns the value as a result if the validation function passes. Otherwise throws an error.
Parameters
val
any
The value to validate.
func
The boolean validation function to check the value.
Returns
any
Throws
Throws an error if the value fails the boolean validation test.
checkDate()
staticcheckDate(val):string
Defined in: core/src/ValidationUtils.ts:34
Validates that the provided string represents a ISO, RFC or UTC date or timestamp.
Parameters
val
string
Returns
string
checkEmail()
staticcheckEmail(val):string
Defined in: core/src/ValidationUtils.ts:48
Validates that the provided string represents a valid e-mail address.
Parameters
val
string
Returns
string
checkEmpty()
staticcheckEmpty(val):any[]
Defined in: core/src/ValidationUtils.ts:58
Validates that the provided array is not empty (nor null/undefined).
Parameters
val
any[]
Returns
any[]
checkIP()
staticcheckIP(val):string
Defined in: core/src/ValidationUtils.ts:68
Validates that the provided string is a valid IP address.
Parameters
val
string
Returns
string
checkJSON()
staticcheckJSON(val):string
Defined in: core/src/ValidationUtils.ts:78
Validates that the provided string is valid JSON (note: uses JSON.parse).
Parameters
val
string
Returns
string
checkName()
staticcheckName(val):string
Defined in: core/src/ValidationUtils.ts:88
Validates that the provided string matches the regexp pattern /[a-zA-Z0-9_-.@:+]+/.
Parameters
val
string
Returns
string
checkNull()
staticcheckNull(val):any
Defined in: core/src/ValidationUtils.ts:98
Validates that the provided object is not null or empty.
Parameters
val
any
Returns
any
checkPhone()
staticcheckPhone(val):string
Defined in: core/src/ValidationUtils.ts:110
Validates that the provided string represents a valid phone number.
Parameters
val
string
Returns
string
checkSemVer()
staticcheckSemVer(val):string
Defined in: core/src/ValidationUtils.ts:120
Validates that the provided string represents a semantic version.
Parameters
val
string
Returns
string
checkURL()
staticcheckURL(val):string
Defined in: core/src/ValidationUtils.ts:130
Validates that the provided string is a valid URL.
Parameters
val
string
Returns
string
checkUUID()
staticcheckUUID(val):string
Defined in: core/src/ValidationUtils.ts:140
Validates that the provided string is a valid UUID.
Parameters
val
string
Returns
string
checkVersion()
staticcheckVersion(val):number
Defined in: core/src/ValidationUtils.ts:150
Validates that the provided value is an entity version number (e.g. value > 0).
Parameters
val
any
Returns
number