Class: Validator

Validator

Generic Validator implementation. Note that all methods here are static, so no need to instance this class; see it as an Utility/Companion class.
Source:
Throws:
instancing not allowed for this class
Type
Error

Methods

(static) doesObjectContainsProperty(objnullable, propNamenullable, includeInheritedopt) → {boolean}

Tell if the given object contains the given property.

Tell if the given object contains the given property.
Parameters:
Name Type Attributes Default Description
obj object <nullable>
the object to check
propName string <nullable>
the name of the property
includeInherited boolean <optional>
false specify if search in nested/inherited properties
Source:
Returns:
true if the object contains theat property, otherwise false
Type
boolean

(static) doesObjectContainsStandardProperty(objnullable, isPropStandardnullable) → {boolean}

Tell if the given object contains at least one property that has a standard (reserved) property name.

Tell if the given object contains at least one property that has a standard (reserved) property name.
Parameters:
Name Type Attributes Description
obj object <nullable>
the object to check
isPropStandard function <nullable>
the function that tell the given argument (property), if it's standard
Source:
Returns:
true if at least one property with a standard name is found, otherwise false
Type
boolean

(static) doesStringIsStandardProperty(strnullable, isPropStandardnullable) → {boolean}

Tell if the given string has a standard (reserved) property name.

Tell if the given string has a standard (reserved) property name.
Parameters:
Name Type Attributes Description
str string <nullable>
the string to check
isPropStandard function <nullable>
the function that tell the given argument (property), if it's standard
Source:
Returns:
true if the given string has a standard name, otherwise false
Type
boolean

(static) ensureIsArray(argnullable, nameopt) → {TypeError}

Ensure that the given argument is an array.

Ensure that the given argument is an array. See Validator.isArray.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
name string <optional>
'arg' the name to use in generated error (or the value of first argument if not given)
Source:
Returns:
if it's not an array, nothing otherwise
Type
TypeError

(static) ensureIsBoolean(argnullable, nameopt) → {TypeError}

Ensure that the given argument is a boolean.

Ensure that the given argument is a boolean. See Validator.isBoolean.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
name string <optional>
'arg' the name to use in generated error (or the value of first argument if not given)
Source:
Returns:
if it's not a boolean, nothing otherwise
Type
TypeError

(static) ensureIsClass(argnullable, classReferencenullable, nameopt) → {TypeError}

Ensure that the given argument is an instance of the given class reference.

Ensure that the given argument is an instance of the given class reference. See Validator.isClass.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
classReference object <nullable>
the class that should be implemented/extended
name string <optional>
'arg' the name to use in generated error (or the value of first argument if not given)
Source:
Returns:
if it's not an instance (or extends) that class, nothing otherwise
Type
TypeError

(static) ensureIsDate(argnullable, nameopt) → {Error}

Ensure that the given argument is a date.

Ensure that the given argument is a date. See Validator.isDate.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
name string <optional>
'arg' the name to use in generated error (or the value of first argument if not given)
Source:
Returns:
if it's not a date, nothing otherwise
Type
Error

(static) ensureIsDateFuture(argnullable, nameopt) → {Error}

Ensure that the given argument is a date in the future or now.

Ensure that the given argument is a date in the future or now. See Validator.isDateFuture.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
name string <optional>
'arg' the name to use in generated error (or the value of first argument if not given)
Source:
Returns:
if it's not a date in the future, nothing otherwise
Type
Error

(static) ensureIsDatePast(argnullable, nameopt) → {Error}

Ensure that the given argument is a date in the past or now.

Ensure that the given argument is a date in the past or now. See Validator.isDatePast.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
name string <optional>
'arg' the name to use in generated error (or the value of first argument if not given)
Source:
Returns:
if it's not a date in the past, nothing otherwise
Type
Error

(static) ensureIsDefinedAndNotNull(argnullable, nameopt) → {TypeError}

Ensure that the given argument is defined and not null.

Ensure that the given argument is defined and not null. See Validator.isDefinedAndNotNull.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
name string <optional>
'arg' the name to use in generated error (or the value of first argument if not given)
Source:
Returns:
if it's not undefined or null, nothing otherwise
Type
TypeError

(static) ensureIsError(argnullable, nameopt) → {Error}

Ensure that the given argument is an error instance or its subclass.

Ensure that the given argument is an error instance or its subclass. See Validator.isError.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
name string <optional>
'arg' the name to use in generated error (or the value of first argument if not given)
Source:
Returns:
if it's not an error or its subclass, nothing otherwise
Type
Error

(static) ensureIsFunction(argnullable, nameopt) → {TypeError}

Ensure that the given argument is a function.

Ensure that the given argument is a function. See Validator.isFunction.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
name string <optional>
'arg' the name to use in generated error (or the value of first argument if not given)
Source:
Returns:
if it's not a function, nothing otherwise
Type
TypeError

(static) ensureIsNull(argnullable, nameopt) → {TypeError}

Ensure that the given argument is null.

Ensure that the given argument is null. See Validator.isNull.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
name string <optional>
'arg' the name to use in generated error (or the value of first argument if not given)
Source:
Returns:
if it's not null, nothing otherwise
Type
TypeError

(static) ensureIsNumber(argnullable, nameopt) → {Error}

Ensure that the given argument is a number.

Ensure that the given argument is a number. See Validator.isNumber.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
name string <optional>
'arg' the name to use in generated error (or the value of first argument if not given)
Source:
Returns:
if it's not a number, nothing otherwise
Type
Error

(static) ensureIsObject(argnullable, nameopt) → {TypeError}

Ensure that the given argument is an object.

Ensure that the given argument is an object. See Validator.isObject.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
name string <optional>
'arg' the name to use in generated error (or the value of first argument if not given)
Source:
Returns:
if it's not an object, nothing otherwise
Type
TypeError

(static) ensureIsObjectOrCollection(argnullable, nameopt) → {TypeError}

Ensure that the given argument is a plain object or a collection.

Ensure that the given argument is a plain object or a collection. See Validator.isObjectOrCollection.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
name string <optional>
'arg' the name to use in generated error (or the value of first argument if not given)
Source:
Returns:
if it's not a plain object nor a collection, nothing otherwise
Type
TypeError

(static) ensureIsObjectOrCollectionNotArray(argnullable, nameopt) → {TypeError}

Ensure that the given argument is a plain object or a collection, not an array.

Ensure that the given argument is a plain object or a collection, not an array. See Validator.isObjectOrCollectionNotArray.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
name string <optional>
'arg' the name to use in generated error (or the value of first argument if not given)
Source:
Returns:
if it's not a plain object nor a collection or it's an array, nothing otherwise
Type
TypeError

(static) ensureIsObjectOrCollectionNotString(argnullable, nameopt) → {TypeError}

Ensure that the given argument is a plain object or a collection, not a string.

Ensure that the given argument is a plain object or a collection, not a string. See Validator.isObjectOrCollectionNotString.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
name string <optional>
'arg' the name to use in generated error (or the value of first argument if not given)
Source:
Returns:
if it's not a plain object nor a collection or it's a string, nothing otherwise
Type
TypeError

(static) ensureIsObjectOrCollectionOrArray(argnullable, nameopt) → {TypeError}

Ensure that the given argument is a plain object or a collection or an array.

Ensure that the given argument is a plain object or a collection or an array. See Validator.isObjectOrCollectionOrArray.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
name string <optional>
'arg' the name to use in generated error (or the value of first argument if not given)
Source:
Returns:
if it's not a plain object nor a collection nor an array, nothing otherwise
Type
TypeError

(static) ensureIsObjectOrCollectionOrArrayNotValue(argnullable, nameopt) → {TypeError}

Ensure that the given argument is a plain object or a collection or an array, not a value (string or boolean or number).

Ensure that the given argument is a plain object or a collection or an array, not a value (string or boolean or number). See Validator.isObjectOrCollectionOrArrayNotValue.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
name string <optional>
'arg' the name to use in generated error (or the value of first argument if not given)
Source:
Returns:
if it's not a plain object nor a collection or it's a value (string or boolean or number), nothing otherwise
Type
TypeError

(static) ensureIsObjectOrCollectionOrArrayOrValue(argnullable, nameopt) → {TypeError}

Ensure that the given argument is a plain object or a collection or an array, or a value (string or boolean or number).

Ensure that the given argument is a plain object or a collection or an array, or a value (string or boolean or number). See Validator.isObjectOrCollectionOrArrayOrValue.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
name string <optional>
'arg' the name to use in generated error (or the value of first argument if not given)
Source:
Returns:
if it's not a plain object nor a collection nor a value (string or boolean or number), nothing otherwise
Type
TypeError

(static) ensureIsObjectOrCollectionOrString(argnullable, nameopt) → {TypeError}

Ensure that the given argument is a plain object or a collection, or a string.

Ensure that the given argument is a plain object or a collection, or a string. See Validator.isObjectOrCollectionOrString.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
name string <optional>
'arg' the name to use in generated error (or the value of first argument if not given)
Source:
Returns:
if it's not a plain object nor a collection nor a string, nothing otherwise
Type
TypeError

(static) ensureIsObjectOrCollectionOrValue(argnullable, nameopt) → {TypeError}

Ensure that the given argument is a plain object or a collection, or a value (string or boolean or number).

Ensure that the given argument is a plain object or a collection, or a value (string or boolean or number). See Validator.isObjectOrCollectionOrValue.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
name string <optional>
'arg' the name to use in generated error (or the value of first argument if not given)
Source:
Returns:
if it's not a plain object nor a collection nor a value (string or boolean or number), nothing otherwise
Type
TypeError

(static) ensureIsObjectPlain(argnullable, nameopt) → {TypeError}

Ensure that the given argument is a plain object and not: undefined, null, Array, Date, Number, String, Symbol, Map/WeakMap, Set/WeakSet, etc.

Ensure that the given argument is a plain object and not: undefined, null, Array, Date, Number, String, Symbol, Map/WeakMap, Set/WeakSet, etc. See Validator.isObjectPlain.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
name string <optional>
'arg' the name to use in generated error (or the value of first argument if not given)
Source:
Returns:
if it's not a plain object, nothing otherwise
Type
TypeError

(static) ensureIsString(argnullable, nameopt) → {TypeError}

Ensure that the given argument is a string.

Ensure that the given argument is a string. See Validator.isString.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
name string <optional>
'arg' the name to use in generated error (or the value of first argument if not given)
Source:
Returns:
if it's not a string, nothing otherwise
Type
TypeError

(static) ensureIsStringNotEmpty(argnullable, nameopt) → {Error}

Ensure that the given argument is a not empty string.

Ensure that the given argument is a not empty string. See Validator.isStringNotEmpty.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
name string <optional>
'arg' the name to use in generated error (or the value of first argument if not given)
Source:
Returns:
if it's not a string not empty, nothing otherwise
Type
Error

(static) ensureIsUndefined(argnullable, nameopt) → {TypeError}

Ensure that the given argument is undefined.

Ensure that the given argument is undefined. See Validator.isUndefined.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
name string <optional>
'arg' the name to use in generated error (or the value of first argument if not given)
Source:
Returns:
if it's not undefined, nothing otherwise
Type
TypeError

(static) ensureIsUndefinedOrNull(argnullable, nameopt) → {TypeError}

Ensure that the given argument is undefined or null.

Ensure that the given argument is undefined or null. See Validator.isUndefinedOrNull.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
name string <optional>
'arg' the name to use in generated error (or the value of first argument if not given)
Source:
Returns:
if it's not undefined or null, nothing otherwise
Type
TypeError

(static) ensureIsURI(argnullable, basenullable, nameopt) → {Error}

Ensure that the given argument is an URI/URL.

Ensure that the given argument is an URI/URL. See Validator.isURI.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
base string <nullable>
the (optional) base to build the full URL
name string <optional>
'arg' the name to use in generated error (or the value of first argument if not given)
Source:
Returns:
if it's not an URI/URL, nothing otherwise
Type
Error

(static) ensureIsValue(argnullable, nameopt) → {TypeError}

Ensure that the given argument is a value (string or boolean or number).

Ensure that the given argument is a value (string or boolean or number). See Validator.isValue.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
name string <optional>
'arg' the name to use in generated error (or the value of first argument if not given)
Source:
Returns:
if it's not a string or a boolean or a number, nothing otherwise
Type
TypeError

(static) ensureIsVersion(argnullable, nameopt) → {Error}

Ensure that the given argument is a string version.

Ensure that the given argument is a string version. See Validator.isVersion.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
name string <optional>
'arg' the name to use in generated error (or the value of first argument if not given)
Source:
Returns:
if it's not a string version, nothing otherwise
Type
Error

(static) ensureObjectContainsProperty(objnullable, propNamenullable, includeInheritedopt, nameopt) → {boolean}

Ensure that the given object contains the given property.

Ensure that the given object contains the given property. See Validator.doesObjectContainsProperty.
Parameters:
Name Type Attributes Default Description
obj object <nullable>
the object to check
propName string <nullable>
the name of the property
includeInherited boolean <optional>
false specify if search in nested/inherited properties
name string <optional>
'arg' the name to use in generated error (for the first argument)
Source:
Returns:
true if the object contains theat property, otherwise false
Type
boolean

(static) ensureObjectDoesNotContainsStandardProperty(argnullable, isPropStandardnullable, nameopt) → {Error}

Ensure that the given object does not contain any property that has a standard (reserved) property name.

Ensure that the given object does not contain any property that has a standard (reserved) property name. See Validator.doesObjectContainsStandardProperty.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
isPropStandard function <nullable>
the function that tell the given argument (property), if it's standard
name string <optional>
'arg' the name to use in generated error (for the first argument)
Source:
Returns:
if at least one property with a standard name is found, nothing otherwise
Type
Error

(static) getArgumentName(argnullable) → {string}

Return the name of the variable given as argument.

Return the name of the variable given as argument. To use it, must be called using the trick to wrap argument inside an object literal, so for example use it inside a template string with: `${getArgumentName({x})}` with nested objects (like with options with a property x inside) you need to use with: `${getArgumentName({options})}.${getArgumentName({x})}`. Note that this could have been written (in a shorter way) as an arrow function.
Parameters:
Name Type Attributes Description
arg object <nullable>
the argument
Source:
Returns:
the name of the variable (if defined and not null), nothing otherwise
Type
string

(static) getArgumentValue(argnullable) → {string}

Return the value of the variable given as argument.

Return the value of the variable given as argument. Note that this could have been written (in a shorter way) as an arrow function.
Parameters:
Name Type Attributes Description
arg object <nullable>
the argument
Source:
Returns:
the value of the variable (if defined and not null), nothing otherwise
Type
string

(static) getObjectFilteredProperties(objnullable, propFilternullable) → {object}

Return a copy of the given ibject, with all properties filtered by the given function (predicate).

Return a copy of the given ibject, with all properties filtered by the given function (predicate).
Parameters:
Name Type Attributes Description
obj object <nullable>
the base object
propFilter function <nullable>
the function (predicate) for filtering properties
Source:
Throws:
if obj is not a plain object, or propFilter is not a function
Type
TypeError
Returns:
a new object containing only filtered properties
Type
object

(static) getOrElse(argnullable, defnullable) → {object}

Return the argument if it's defined and not null, otherwise the given default value is returned.

Return the argument if it's defined and not null, otherwise the given default value is returned.
Parameters:
Name Type Attributes Description
arg object <nullable>
the argument to return
def object <nullable>
the default value to return
Source:
Returns:
the argument (if defined and not null), otherwise the default value
Type
object

(static) getSize(argnullable) → {number}

Tell the size of the given object.

Tell the size of the given object
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
Source:
Throws:
if it's not an array nor a collection nor object nor a string
Type
TypeError
Returns:
the size if it's an array|Map|Set|object|string, nothing otherwise
Type
number

(static) getSizeInBytes(strnullable) → {number}

Tell the size in bytes of the given string.

Tell the size in bytes of the given string.
Parameters:
Name Type Attributes Description
str string <nullable>
the string to check
Source:
Throws:
if it's not a string
Type
TypeError
Returns:
the size if it's a string, nothing otherwise
Type
number

(static) isArray(argnullable) → {boolean}

Tell if the given argument is an array.

Tell if the given argument is an array.
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
Source:
Returns:
true if it's an array, false otherwise
Type
boolean

(static) isBoolean(argnullable) → {boolean}

Tell if the given argument is a boolean.

Tell if the given argument is a boolean.
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
Source:
Returns:
true if it's a boolean, false otherwise
Type
boolean

(static) isClass(argnullable, classReferencenullable) → {boolean}

Tell if the given argument is an instance of the given class reference.

Tell if the given argument is an instance of the given class reference.
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
classReference object <nullable>
the class that should be implemented/extended
Source:
Returns:
true if it's an instance (or extends) that class, false otherwise
Type
boolean

(static) isDate(argnullable) → {boolean}

Tell if the given argument is a date.

Tell if the given argument is a date.
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
Source:
Returns:
true if it's a date, false otherwise
Type
boolean

(static) isDateFuture(argnullable) → {boolean}

Tell if the given argument is a valid date and in the future or now.

Tell if the given argument is a valid date and in the future or now. See Validator.isDateValid.
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
Source:
Returns:
true if it's a valid date in the future (or now), false otherwise
Type
boolean

(static) isDatePast(argnullable) → {boolean}

Tell if the given argument is a valid date and in the past or now.

Tell if the given argument is a valid date and in the past or now. See Validator.isDateValid.
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
Source:
Returns:
true if it's a valid date in the past (or now), false otherwise
Type
boolean

(static) isDateValid(argnullable) → {boolean}

Tell if the given argument is a valid date.

Tell if the given argument is a valid date. See Validator.isDate.
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
Source:
Returns:
true if it's a valid date, false otherwise
Type
boolean

(static) isDefinedAndNotNull(argnullable) → {boolean}

Tell if the given argument is defined and not null.

Tell if the given argument is defined and not null.
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
Source:
Returns:
true if defined and not null, false otherwise
Type
boolean

(static) isError(argnullable) → {boolean}

Tell if the given argument is an error.

Tell if the given argument is an error.
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
Source:
Returns:
true if it's an error, false otherwise
Type
boolean

(static) isFunction(argnullable) → {boolean}

Tell if the given argument is a function.

Tell if the given argument is a function.
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
Source:
Returns:
true if it's a function, false otherwise
Type
boolean

(static) isKeyedCollection(argnullable) → {boolean}

Tell if the given argument is a keyed collection.

Tell if the given argument is a keyed collection.
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
Source:
Returns:
true if it's a Map|WeakMap or a Set|WeakSet, false otherwise
Type
boolean

(static) isNull(argnullable) → {boolean}

Tell if the given argument is null.

Tell if the given argument is null.
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
Source:
Returns:
true if null, false otherwise
Type
boolean

(static) isNumber(argnullable) → {boolean}

Tell if the given argument is a number.

Tell if the given argument is a number.
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
Source:
Returns:
true if it's a number, false otherwise
Type
boolean

(static) isObject(argnullable) → {boolean}

Tell if the given argument is an object and is defined and not null.

Tell if the given argument is an object and is defined and not null.
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
Source:
Returns:
true if it's an object, false otherwise
Type
boolean

(static) isObjectOrCollection(argnullable) → {boolean}

Tell if the given argument is a plain object or a keyed collection.

Tell if the given argument is a plain object or a keyed collection. See Validator.isObject, Validator.isKeyedCollection.
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
Source:
Returns:
true if it's a plain object or a keyed collection, false otherwise
Type
boolean

(static) isObjectOrCollectionNotArray(argnullable) → {boolean}

Tell if the given argument is a plain object or a keyed collection, but not an array.

Tell if the given argument is a plain object or a keyed collection, but not an array. See Validator.isObjectOrCollection. See Validator.isArray.
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
Source:
Returns:
true if it's a plain object or a keyed collection but not an array, false otherwise
Type
boolean

(static) isObjectOrCollectionNotString(argnullable) → {boolean}

Tell if the given argument is a plain object or a keyed collection, but not a string.

Tell if the given argument is a plain object or a keyed collection, but not a string. See Validator.isObjectOrCollection.
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
Source:
Returns:
true if it's a plain object or a keyed collection but not a string, false otherwise
Type
boolean

(static) isObjectOrCollectionOrArray(argnullable) → {boolean}

Tell if the given argument is a plain object or a keyed collection or an array.

Tell if the given argument is a plain object or a keyed collection or an array. See Validator.isObjectOrCollection. See Validator.isArray.
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
Source:
Returns:
true if it's a plain object or a keyed collection or an array, false otherwise
Type
boolean

(static) isObjectOrCollectionOrArrayNotValue(argnullable) → {boolean}

Tell if the given argument is a plain object or a keyed collection or an array, but not a value (string or boolean or number).

Tell if the given argument is a plain object or a keyed collection or an array, but not a value (string or boolean or number). See Validator.isObjectOrCollection. See Validator.isArray. See Validator.isValue.
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
Source:
Returns:
true if it's a plain object or a keyed collection or an array but not a value (string or boolean or number), false otherwise
Type
boolean

(static) isObjectOrCollectionOrArrayOrValue(argnullable) → {boolean}

Tell if the given argument is a plain object or a keyed collection or an array, or a value (string or boolean or number).

Tell if the given argument is a plain object or a keyed collection or an array, or a value (string or boolean or number). See Validator.isObjectOrCollection. See Validator.isArray. See Validator.isValuey.
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
Source:
Returns:
true if it's a plain object or a keyed collection or an array or a value (string or boolean or number), false otherwise
Type
boolean

(static) isObjectOrCollectionOrString(argnullable) → {boolean}

Tell if the given argument is a plain object or a keyed collection, or a string.

Tell if the given argument is a plain object or a keyed collection, or a string. See Validator.isObjectOrCollection.
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
Source:
Returns:
true if it's a plain object or a keyed collection or a string, false otherwise
Type
boolean

(static) isObjectOrCollectionOrValue(argnullable) → {boolean}

Tell if the given argument is a plain object or a keyed collection, or a value (string or boolean or number).

Tell if the given argument is a plain object or a keyed collection, or a value (string or boolean or number). See Validator.isObjectOrCollection. See Validator.isValuey.
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
Source:
Returns:
true if it's a plain object or a keyed collection or a value (string or boolean or number), false otherwise
Type
boolean

(static) isObjectPlain(argnullable) → {boolean}

Tell if the given argument is a plain object and not: undefined, null, Array, Date, Number, String, Symbol, Map/WeakMap, Set/WeakSet, etc.

Tell if the given argument is a plain object and not: undefined, null, Array, Date, Number, String, Symbol, Map/WeakMap, Set/WeakSet, etc.
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
Source:
Returns:
true if it's a plain object, false otherwise
Type
boolean

(static) isString(argnullable) → {boolean}

Tell if the given argument is a string.

Tell if the given argument is a string.
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
Source:
Returns:
true if it's a string, false otherwise
Type
boolean

(static) isStringNotEmpty(argnullable) → {boolean}

Tell if the given argument is a not empty string.

Tell if the given argument is a not empty string. See Validator.isString.
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
Source:
Returns:
true if it's a not empty string, false otherwise
Type
boolean

(static) isUndefined(argnullable) → {boolean}

Tell if the given argument is undefined.

Tell if the given argument is undefined.
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
Source:
Returns:
true if undefined, false otherwise
Type
boolean

(static) isUndefinedOrNull(argnullable) → {boolean}

Tell if the given argument is undefined or null.

Tell if the given argument is undefined or null.
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
Source:
Returns:
true if undefined or null, false otherwise
Type
boolean

(static) isURI(argnullable, basenullable) → {boolean}

Tell if the given argument is an URI or an URL.

Tell if the given argument is an URI or an URL.
Parameters:
Name Type Attributes Description
arg string <nullable>
the uri/url to check
base string <nullable>
the (optional) base to build the full URL
Source:
Returns:
true if it's an URI/URL, false otherwise
Type
boolean

(static) isValue(argnullable) → {boolean}

Tell if the given argument is a normal value (string or boolean or number).

Tell if the given argument is a normal value (string or boolean or number).
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
Source:
Returns:
true if it's a string or boolean or number, false otherwise
Type
boolean

(static) isVersion(argnullable) → {boolean}

Tell if the given argument is a string representation of a version number.

Tell if the given argument is a string representation of a version number. Note that the version string could be something like: - as minimum a number is needed for an integer version - at the beginning I can have an optional char 'v' or 'V' - anything after the third number will be considered as a string - format updated to handle version output of 'git describe'
Parameters:
Name Type Attributes Description
arg string <nullable>
the version string to check
Source:
Returns:
true if it's a version string, false otherwise
Type
boolean

(static) throwOnError(argnullable)

Throw if the given argument is an error instance or its subclass.

Throw if the given argument is an error instance or its subclass. See Validator.isError.
Parameters:
Name Type Attributes Description
arg object <nullable>
the object to check
Source:
Throws:
the given error
Type
Error

(static) throwOnFalse(argnullable, nameopt)

Throw if the given argument is false.

Throw if the given argument is false. Note that this is similar to assertions. See Validator.isError.
Parameters:
Name Type Attributes Default Description
arg object <nullable>
the object to check
name string <optional>
'arg' the name to use in generated error (or the value of first argument if not given)
Source:
Throws:
if the given argument is not a boolean, or if it's false
Type
Error