Class: ValidationUtils
Defined in: core/src/ValidationUtils.ts:14
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:23
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:33
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:47
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:57
Validates that the provided array is not empty.
Parameters
val
any[]
Returns
any[]
checkIP()
staticcheckIP(val):string
Defined in: core/src/ValidationUtils.ts:67
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:77
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:87
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:97
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:107
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:117
Validates that the provided string represents a semantic version.
Parameters
val
string
Returns
string
checkURL()
staticcheckURL(val):string
Defined in: core/src/ValidationUtils.ts:127
Validates that the provided string is a valid URL.
Parameters
val
string
Returns
string
checkUUID()
staticcheckUUID(val):string
Defined in: core/src/ValidationUtils.ts:137
Validates that the provided string is a valid UUID.
Parameters
val
string
Returns
string
checkVersion()
staticcheckVersion(val):number
Defined in: core/src/ValidationUtils.ts:147
Validates that the provided value is an entity version number (e.g. value > 0).
Parameters
val
any
Returns
number