Validate class
Performs common validation tests for properties and function parameters.
Remarks
This class implements provides a standard way to validate properties and function parameters. Unlike debug assertions, Validate checks are always performed and will always throw an error, even in a production release. As such, be careful not to overuse these checks in a way that might impact performance.
Methods
is |
Throws an exception if the specified string is null, undefined, or an empty string. |
is |
Throws an exception if the specified object has been disposed. |
is |
Throws an exception if the specified value is null or undefined. |
is |
Throws an exception if the specified value is not true. |
Method Details
isNonemptyString(value, variableName)
Throws an exception if the specified string is null, undefined, or an empty string.
static isNonemptyString(value: string | undefined | null, variableName: string): void;
Parameters
- value
-
string | undefined | null
the value to check
- variableName
-
string
the program variable name, which will be mentioned in the error message
Returns
void
isNotDisposed(value, className)
Throws an exception if the specified object has been disposed.
static isNotDisposed(value: IDisposable, className: string): void;
Parameters
- value
- IDisposable
the value to check
- className
-
string
the class name, which will be mentioned in the error message
Returns
void
isNotNullOrUndefined(value, variableName)
Throws an exception if the specified value is null or undefined.
static isNotNullOrUndefined(value: unknown, variableName: string): void;
Parameters
- value
-
unknown
the value to check
- variableName
-
string
the program variable name, which will be mentioned in the error message
Returns
void
isTrue(value, variableName)
Throws an exception if the specified value is not true.
static isTrue(value: boolean | undefined | null, variableName: string): void;
Parameters
- value
-
boolean | undefined | null
the value to check
- variableName
-
string
the program variable name, which will be mentioned in the error message
Returns
void