isNull
Checks whether a value is null.
This helper performs a strict equality check and never throws or mutates input. Use it when you need to confirm that a value is explicitly null before running normalization or validation.
Signature
function isNull(value: unknown): value is null
Parameters
| Name | Data type | Description |
|---|---|---|
| value | unknown |
The value to check. This helper returns true only when the value is exactly null. |
Returns
A boolean:
true: If the value is null.false: Otherwise.
Examples
isNull(null) // true
isNull(undefined) // false
isNull(0) // false
isNull('') // false
isNull({}) // false
Notes
- This helper does not treat
undefinedasnull. Use isNullOrUndefined if you need to check for both. - Use
normalizeNullif you need to convert values intonull. - Use
validateNullif you need aResult<T>instead of a boolean.