Skip to main content

@rtorcato/js-common / validation

validation

Functions

isDefined()

isDefined<T>(value): value is T

Defined in: validation/index.ts:6

Checks if a value is defined (not null or undefined).

Type Parameters

T

T

Parameters

value

T | null | undefined

The value to check.

Returns

value is T


isString()

isString(value): value is string

Defined in: validation/index.ts:16

Check if a value is a string.

Parameters

value

unknown

The value to check.

Returns

value is string

true if the value is a string, false otherwise.


isNumber()

isNumber(value): value is number

Defined in: validation/index.ts:26

Checks if a value is a number (and not NaN).

Parameters

value

unknown

The value to check.

Returns

value is number


isBoolean()

isBoolean(value): value is boolean

Defined in: validation/index.ts:36

Checks if a value is a boolean.

Parameters

value

unknown

The value to check.

Returns

value is boolean


isArray()

isArray(value): value is unknown[]

Defined in: validation/index.ts:46

Checks if a value is an array.

Parameters

value

unknown

The value to check.

Returns

value is unknown[]


isObject()

isObject(value): value is object

Defined in: validation/index.ts:56

Checks if a value is an object (but not null or array).

Parameters

value

unknown

The value to check.

Returns

value is object


isEmail()

isEmail(str): boolean

Defined in: validation/index.ts:65

Checks if a string is a valid email address (simple regex).

Parameters

str

string

The string to check.

Returns

boolean


isUrl()

isUrl(str): boolean

Defined in: validation/index.ts:74

Checks if a string is a valid URL.

Parameters

str

string

The string to check.

Returns

boolean