Function to validate types
Signed-off-by: Fabio José <fabiojose@gmail.com>
This commit is contained in:
parent
1905266d1f
commit
0b9bf5a548
|
@ -3,6 +3,11 @@ const isString = (v) => (typeof v) === "string";
|
|||
const isObject = (v) => (typeof v) === "object";
|
||||
const isDefined = (v) => v && (typeof v) != "undefined";
|
||||
|
||||
const isBoolean = (v) => (typeof v) === "boolean";
|
||||
const isInteger = (v) => Number.isInteger(v);
|
||||
const isDate = (v) => (v instanceof Date);
|
||||
const isBinary = (v) => (v instanceof ArrayBuffer);
|
||||
|
||||
const isStringOrThrow = (v, t) =>
|
||||
(isString(v)
|
||||
? true
|
||||
|
@ -47,6 +52,11 @@ module.exports = {
|
|||
isObject,
|
||||
isDefined,
|
||||
|
||||
isBoolean,
|
||||
isInteger,
|
||||
isDate,
|
||||
isBinary,
|
||||
|
||||
isDefinedOrThrow,
|
||||
isStringOrObjectOrThrow,
|
||||
|
||||
|
|
Loading…
Reference in New Issue