API Docs for: 0.8.0
Show:

ValidationService Class

Provides a set of functions for common validations.

Constructor

ValidationService

()

Item Index

Methods

Properties

  • static
  • static
  • static
  • static
  • static

Methods

isArray

(
  • value
  • [required=false]
)

Validates an array

Parameters:

  • value Array
  • [required=false] Boolean optional

isBool

(
  • val
)
Boolean static

Validates that the value is a boolean.

Parameters:

  • val

    The value under test

Returns:

Boolean:

TRUE if the value is valid, FALSE if not

isDate

(
  • val
  • [required=false]
)
Boolean static

Validates that the value is a date object

Parameters:

  • val

    The value under test

  • [required=false] Boolean optional

Returns:

Boolean:

TRUE if the value is valid, FALSE if not

isEmail

(
  • value
  • [required=false]
)

Validates an email address

Parameters:

  • value String
  • [required=false] Boolean optional

isEmpty

(
  • val
)
Boolean static

Validates that the value is null, defined, an empty object, and empty array or an empty string.

Parameters:

  • val

    The value under test

Returns:

Boolean:

TRUE if the value is valid, FALSE if not

isFloat

(
  • val
  • [required=false]
  • strict
)
Boolean static

Validates that the value is a float.

Parameters:

  • val

    The value under test

  • [required=false] Boolean optional

    Indicates if the value is required. When FALSE, null will be an acceptable value.

  • strict Boolean

    Indicates if the value must be a number rather than a string representing a number.

Returns:

Boolean:

TRUE if the value is valid, FALSE if not

isId

(
  • val
  • [required=false]
)
Boolean static

Checks to see if the value is a valid ID string or an instance of ObjectID.

Parameters:

  • val String | ObjectID

    The value under test

  • [required=false] Boolean optional

    Indicates if the value is required. When FALSE, null will be an acceptable value.

Returns:

Boolean:

TRUE if the value is valid, FALSE if not

isIdStr

(
  • val
  • [required=false]
)
Boolean static

Checks to see if the value is a valid ID string

Parameters:

  • val String

    The value under test

  • [required=false] Boolean optional

    Indicates if the value is required. When FALSE, null will be an acceptable value.

Returns:

Boolean:

TRUE if the value is valid, FALSE if not

isInt

(
  • val
  • [required=false]
  • strict
)
Boolean static

Validates that the value is an integer.

Parameters:

  • val Integer

    The value under test

  • [required=false] Boolean optional

    Indicates if the value is required. When FALSE, null will be an acceptable value.

  • strict Boolean

    Indicates if the value must be a number rather than a string representing a number.

Returns:

Boolean:

TRUE if the value is valid, FALSE if not

isNonEmptyStr

(
  • value
  • [required=false]
)

Validates a string is not empty

Parameters:

  • value String
  • [required=false] Boolean optional

isNum

(
  • val
  • [required=false]
)
Boolean static

Validates that the value is a number.

Parameters:

  • val

    The value under test

  • [required=false] Boolean optional

    Indicates if the value is required. When FALSE, null will be an acceptable value.

Returns:

Boolean:

TRUE if the value is valid, FALSE if not

isObject

(
  • value
  • [required=false]
)

Validates an object

Parameters:

  • value Object
  • [required=false] Boolean optional

isSafeFileName

(
  • value
  • [required=false]
)

Validates a file name

Parameters:

  • value String
  • [required=false] Boolean optional

isStr

(
  • value
  • [required=false]
)

Validates a string

Parameters:

  • value String
  • [required=false] Boolean optional

isUrl

(
  • value
  • [required=false]
)

Validates an URL

Parameters:

  • value String
  • [required=false] Boolean optional

isVersionExpression

(
  • expression
  • [required=false]
)

Validates a version expression

Parameters:

  • expression String
  • [required=false] Boolean optional

isVersionNum

(
  • value
  • [required=false]
)

Validates a version number

Parameters:

  • value String
  • [required=false] Boolean optional

validateArray

(
  • value
  • [required=false]
)
deprecated

Validates an array

Parameters:

  • value Array
  • [required=false] Boolean optional

validateEmail

(
  • value
  • [required=false]
)
deprecated

Validates an email address

Parameters:

  • value String
  • [required=false] Boolean optional

validateNonEmptyStr

(
  • value
  • [required=false]
)
deprecated

Validates a string is not empty

Parameters:

  • value String
  • [required=false] Boolean optional

validateObject

(
  • value
  • [required=false]
)
deprecated

Validates an object

Parameters:

  • value Object
  • [required=false] Boolean optional

validateSafeFileName

(
  • value
  • [required=false]
)
deprecated

Validates a file name

Parameters:

  • value String
  • [required=false] Boolean optional

validateStr

(
  • value
  • [required=false]
)
deprecated

Validates a string

Parameters:

  • value String
  • [required=false] Boolean optional

validateUrl

(
  • value
  • [required=false]
)
deprecated

Validates an URL

Parameters:

  • value String
  • [required=false] Boolean optional

validateVersionNum

(
  • value
  • [required=false]
)
deprecated

Validates a version number

Parameters:

  • value String
  • [required=false] Boolean optional

Properties

RegExp private static

Pattern to validate a file name

RegExp private static

Pattern to validate a semantic package version

RegExp private static

A pattern to validate an email address

RegExp private static

A pattern to validate a fully qualified URL

RegExp private static

A pattern to validate a relative URL (no protocol, host, or port)