@transferwise/neptune-validation
Version:
Neptune Web validation
14 lines (12 loc) • 830 B
text/typescript
export const isString = (value: unknown): value is string => typeof value === 'string';
export const isNumber = (value: unknown): value is number =>
typeof value === 'number' && !Number.isNaN(value);
export const isInteger = (value: unknown): value is number => {
return isNumber(value) && Math.floor(value) === value;
};
export const isBoolean = (value: unknown): value is boolean => typeof value === 'boolean';
export const isObject = (value: unknown): value is Record<string, unknown> =>
typeof value === 'object' && !isNull(value) && value.constructor === Object;
export const isArray = (value: unknown): value is unknown[] => Array.isArray(value);
export const isNull = (value: unknown): value is null => value === null;
export const isUndefined = (value: unknown): value is undefined => typeof value === 'undefined';