Options
All
  • Public
  • Public/Protected
  • All
Menu

Project data-transfer-object

Index

Classes

Interfaces

Type aliases

Variables

Functions

Type aliases

ArrayUniqueIdentifier

ArrayUniqueIdentifier<T>: (o: T) => any

Type parameters

  • T = any

Type declaration

    • (o: T): any
    • Parameters

      • o: T

      Returns any

Data

Data<T>: Pick<T, NonFunctionPropertyNames<T>>

Extract the data properties out of a Data Transfer Object.

Type parameters

  • T

IsISBNVersion

IsISBNVersion: "10" | "13" | 10 | 13

IsIpVersion

IsIpVersion: "4" | "6" | 4 | 6

UUIDVersion

UUIDVersion: "3" | "4" | "5" | "all" | 3 | 4 | 5

ValidationErrorHandler

ValidationErrorHandler: (errors: ValidationError[]) => void

Type declaration

ValidationErrorMap

ValidationErrorMap: {}

An object with key-value pairs where the keys represent a property name, and the values are an array of all validation error messages for that property.

Type declaration

  • [property: string]: string[]

ValidationErrorMapHandler

ValidationErrorMapHandler: (errorMap: ValidationErrorMap) => void

Type declaration

Variables

Const ARRAY_CONTAINS

ARRAY_CONTAINS: "arrayContains" = "arrayContains"

Const ARRAY_MAX_SIZE

ARRAY_MAX_SIZE: "arrayMaxSize" = "arrayMaxSize"

Const ARRAY_MIN_SIZE

ARRAY_MIN_SIZE: "arrayMinSize" = "arrayMinSize"

Const ARRAY_NOT_CONTAINS

ARRAY_NOT_CONTAINS: "arrayNotContains" = "arrayNotContains"

Const ARRAY_NOT_EMPTY

ARRAY_NOT_EMPTY: "arrayNotEmpty" = "arrayNotEmpty"

Const ARRAY_UNIQUE

ARRAY_UNIQUE: "arrayUnique" = "arrayUnique"

Const CONTAINS

CONTAINS: "contains" = "contains"

Const EQUALS

EQUALS: "equals" = "equals"

Const IS_ALPHA

IS_ALPHA: "isAlpha" = "isAlpha"

Const IS_ALPHANUMERIC

IS_ALPHANUMERIC: "isAlphanumeric" = "isAlphanumeric"

Const IS_ARRAY

IS_ARRAY: "isArray" = "isArray"

Const IS_ASCII

IS_ASCII: "isAscii" = "isAscii"

Const IS_BASE32

IS_BASE32: "isBase32" = "isBase32"

Const IS_BASE64

IS_BASE64: "isBase64" = "isBase64"

Const IS_BIC

IS_BIC: "isBIC" = "isBIC"

Const IS_BOOLEAN

IS_BOOLEAN: "isBoolean" = "isBoolean"

Const IS_BOOLEAN_STRING

IS_BOOLEAN_STRING: "isBooleanString" = "isBooleanString"

Const IS_BTC_ADDRESS

IS_BTC_ADDRESS: "isBtcAddress" = "isBtcAddress"

Const IS_BYTE_LENGTH

IS_BYTE_LENGTH: "isByteLength" = "isByteLength"

Const IS_CREDIT_CARD

IS_CREDIT_CARD: "isCreditCard" = "isCreditCard"

Const IS_CURRENCY

IS_CURRENCY: "isCurrency" = "isCurrency"

Const IS_DATA_URI

IS_DATA_URI: "isDataURI" = "isDataURI"

Const IS_DATE

IS_DATE: "isDate" = "isDate"

Const IS_DATE_STRING

IS_DATE_STRING: "isDateString" = "isDateString"

Const IS_DECIMAL

IS_DECIMAL: "isDecimal" = "isDecimal"

Const IS_DEFINED

IS_DEFINED: string

Const IS_DIVISIBLE_BY

IS_DIVISIBLE_BY: "isDivisibleBy" = "isDivisibleBy"

Const IS_EAN

IS_EAN: "isEAN" = "isEAN"

Const IS_EMAIL

IS_EMAIL: "isEmail" = "isEmail"

Const IS_EMPTY

IS_EMPTY: "isEmpty" = "isEmpty"

Const IS_ENUM

IS_ENUM: "isEnum" = "isEnum"

Const IS_ETHEREUM_ADDRESS

IS_ETHEREUM_ADDRESS: "isEthereumAddress" = "isEthereumAddress"

Const IS_FIREBASE_PUSH_ID

IS_FIREBASE_PUSH_ID: "IsFirebasePushId" = "IsFirebasePushId"

Const IS_FQDN

IS_FQDN: "isFqdn" = "isFqdn"

Const IS_FULL_WIDTH

IS_FULL_WIDTH: "isFullWidth" = "isFullWidth"

Const IS_HALF_WIDTH

IS_HALF_WIDTH: "isHalfWidth" = "isHalfWidth"

Const IS_HASH

IS_HASH: "isHash" = "isHash"

Const IS_HEXADECIMAL

IS_HEXADECIMAL: "isHexadecimal" = "isHexadecimal"

Const IS_HEX_COLOR

IS_HEX_COLOR: "isHexColor" = "isHexColor"

Const IS_HSL

IS_HSL: "isHSL" = "isHSL"

Const IS_IBAN

IS_IBAN: "isIBAN" = "isIBAN"

Const IS_IDENTITY_CARD

IS_IDENTITY_CARD: "isIdentityCard" = "isIdentityCard"

Const IS_IN

IS_IN: "isIn" = "isIn"

Const IS_INSTANCE

IS_INSTANCE: "isInstance" = "isInstance"

Const IS_INT

IS_INT: "isInt" = "isInt"

Const IS_IP

IS_IP: "isIp" = "isIp"

Const IS_ISBN

IS_ISBN: "isIsbn" = "isIsbn"

Const IS_ISIN

IS_ISIN: "isIsin" = "isIsin"

Const IS_ISO31661_ALPHA_2

IS_ISO31661_ALPHA_2: "isISO31661Alpha2" = "isISO31661Alpha2"

Const IS_ISO31661_ALPHA_3

IS_ISO31661_ALPHA_3: "isISO31661Alpha3" = "isISO31661Alpha3"

Const IS_ISO8601

IS_ISO8601: "isIso8601" = "isIso8601"

Const IS_ISRC

IS_ISRC: "isISRC" = "isISRC"

Const IS_ISSN

IS_ISSN: "isISSN" = "isISSN"

Const IS_JSON

IS_JSON: "isJson" = "isJson"

Const IS_JWT

IS_JWT: "isJwt" = "isJwt"

Const IS_LATITUDE

IS_LATITUDE: "isLatitude" = "isLatitude"

Const IS_LATLONG

IS_LATLONG: "isLatLong" = "isLatLong"

Const IS_LENGTH

IS_LENGTH: "isLength" = "isLength"

Const IS_LOCALE

IS_LOCALE: "isLocale" = "isLocale"

Const IS_LONGITUDE

IS_LONGITUDE: "isLongitude" = "isLongitude"

Const IS_LOWERCASE

IS_LOWERCASE: "isLowercase" = "isLowercase"

Const IS_MAC_ADDRESS

IS_MAC_ADDRESS: "isMacAddress" = "isMacAddress"

Const IS_MAGNET_URI

IS_MAGNET_URI: "isMagnetURI" = "isMagnetURI"

Const IS_MILITARY_TIME

IS_MILITARY_TIME: "isMilitaryTime" = "isMilitaryTime"

Const IS_MIME_TYPE

IS_MIME_TYPE: "isMimeType" = "isMimeType"

Const IS_MOBILE_PHONE

IS_MOBILE_PHONE: "isMobilePhone" = "isMobilePhone"

Const IS_MONGO_ID

IS_MONGO_ID: "isMongoId" = "isMongoId"

Const IS_MULTIBYTE

IS_MULTIBYTE: "isMultibyte" = "isMultibyte"

Const IS_NEGATIVE

IS_NEGATIVE: "isNegative" = "isNegative"

Const IS_NOT_EMPTY

IS_NOT_EMPTY: "isNotEmpty" = "isNotEmpty"

Const IS_NOT_EMPTY_OBJECT

IS_NOT_EMPTY_OBJECT: "isNotEmptyObject" = "isNotEmptyObject"

Const IS_NOT_IN

IS_NOT_IN: "isNotIn" = "isNotIn"

Const IS_NUMBER

IS_NUMBER: "isNumber" = "isNumber"

Const IS_NUMBER_STRING

IS_NUMBER_STRING: "isNumberString" = "isNumberString"

Const IS_OBJECT

IS_OBJECT: "isObject" = "isObject"

Const IS_OCTAL

IS_OCTAL: "isOctal" = "isOctal"

Const IS_PASSPORT_NUMBER

IS_PASSPORT_NUMBER: "isPassportNumber" = "isPassportNumber"

Const IS_PHONE_NUMBER

IS_PHONE_NUMBER: "isPhoneNumber" = "isPhoneNumber"

Const IS_PORT

IS_PORT: "isPort" = "isPort"

Const IS_POSITIVE

IS_POSITIVE: "isPositive" = "isPositive"

Const IS_POSTAL_CODE

IS_POSTAL_CODE: "isPostalCode" = "isPostalCode"

Const IS_RFC_3339

IS_RFC_3339: "isRFC3339" = "isRFC3339"

Const IS_RGB_COLOR

IS_RGB_COLOR: "isRgbColor" = "isRgbColor"

Const IS_SEM_VER

IS_SEM_VER: "isSemVer" = "isSemVer"

Const IS_STRING

IS_STRING: "isString" = "isString"

Const IS_SURROGATE_PAIR

IS_SURROGATE_PAIR: "isSurrogatePair" = "isSurrogatePair"

Const IS_UPPERCASE

IS_UPPERCASE: "isUppercase" = "isUppercase"

Const IS_URL

IS_URL: "isUrl" = "isUrl"

Const IS_UUID

IS_UUID: "isUuid" = "isUuid"

Const IS_VARIABLE_WIDTH

IS_VARIABLE_WIDTH: "isVariableWidth" = "isVariableWidth"

Const MATCHES

MATCHES: "matches" = "matches"

Const MAX

MAX: "max" = "max"

Const MAX_DATE

MAX_DATE: "maxDate" = "maxDate"

Const MAX_LENGTH

MAX_LENGTH: "maxLength" = "maxLength"

Const MIN

MIN: "min" = "min"

Const MIN_DATE

MIN_DATE: "minDate" = "minDate"

Const MIN_LENGTH

MIN_LENGTH: "minLength" = "minLength"

Const NOT_CONTAINS

NOT_CONTAINS: "notContains" = "notContains"

Const NOT_EQUALS

NOT_EQUALS: "notEquals" = "notEquals"

Let onValidationError

onValidationError: ValidationErrorHandler | undefined

The currently set custom validation error handler, if any. To set this, use .setValidationErrorHandler().

Functions

Allow

  • If object has both allowed and not allowed properties a validation error will be thrown.

    Parameters

    Returns PropertyDecorator

ArrayContains

  • ArrayContains(values: any[], validationOptions?: ValidationOptions): PropertyDecorator
  • Checks if array contains all values from the given array of values. If null or undefined is given then this function returns false.

    Parameters

    Returns PropertyDecorator

ArrayMaxSize

  • ArrayMaxSize(max: number, validationOptions?: ValidationOptions): PropertyDecorator
  • Checks if the array's length is less or equal to the specified number. If null or undefined is given then this function returns false.

    Parameters

    Returns PropertyDecorator

ArrayMinSize

  • ArrayMinSize(min: number, validationOptions?: ValidationOptions): PropertyDecorator
  • Checks if the array's length is greater than or equal to the specified number. If null or undefined is given then this function returns false.

    Parameters

    Returns PropertyDecorator

ArrayNotContains

  • ArrayNotContains(values: any[], validationOptions?: ValidationOptions): PropertyDecorator
  • Checks if array does not contain any of the given values. If null or undefined is given then this function returns false.

    Parameters

    Returns PropertyDecorator

ArrayNotEmpty

  • Checks if given array is not empty. If null or undefined is given then this function returns false.

    Parameters

    Returns PropertyDecorator

ArrayUnique

  • Checks if all array's values are unique. Comparison for objects is reference-based. If null or undefined is given then this function returns false.

    Type parameters

    • T = any

    Parameters

    Returns PropertyDecorator

Contains

  • Checks if the string contains the seed. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

Equals

  • Checks if value matches ("===") the comparison.

    Parameters

    Returns PropertyDecorator

IsAlpha

  • Checks if the string contains only letters (a-zA-Z). If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsAlphanumeric

  • IsAlphanumeric(locale?: string, validationOptions?: ValidationOptions): PropertyDecorator
  • Checks if the string contains only letters and numbers. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsArray

  • Checks if a given value is an array

    Parameters

    Returns PropertyDecorator

IsAscii

  • Checks if the string contains ASCII chars only. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsBIC

  • Check if a string is a BIC (Bank Identification Code) or SWIFT code. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsBase32

  • Check if a string is base32 encoded. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsBase64

  • Checks if a string is base64 encoded. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsBoolean

  • Checks if a value is a boolean.

    Parameters

    Returns PropertyDecorator

IsBooleanString

  • Checks if a string is a boolean. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsBtcAddress

  • Check if the string is a valid BTC address. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsByteLength

  • IsByteLength(min: number, max?: number, validationOptions?: ValidationOptions): PropertyDecorator
  • Checks if the string's length (in bytes) falls in a range. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsCreditCard

  • Checks if the string is a credit card. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsCurrency

  • IsCurrency(options?: ValidatorJS.IsCurrencyOptions, validationOptions?: ValidationOptions): PropertyDecorator
  • Checks if the string is a valid currency amount. If given value is not a string, then it returns false.

    Parameters

    • Optional options: ValidatorJS.IsCurrencyOptions
    • Optional validationOptions: ValidationOptions

    Returns PropertyDecorator

IsDataURI

  • Check if the string is a data uri format. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsDate

  • Checks if a value is a date.

    Parameters

    Returns PropertyDecorator

IsDateString

  • IsDateString(options?: ValidatorJS.IsISO8601Options, validationOptions?: ValidationOptions): PropertyDecorator
  • Alias for IsISO8601 validator

    Parameters

    • Optional options: ValidatorJS.IsISO8601Options
    • Optional validationOptions: ValidationOptions

    Returns PropertyDecorator

IsDecimal

  • IsDecimal(options?: ValidatorJS.IsDecimalOptions, validationOptions?: ValidationOptions): PropertyDecorator
  • Checks if the string contains only letters and numbers. If given value is not a string, then it returns false.

    Parameters

    • Optional options: ValidatorJS.IsDecimalOptions
    • Optional validationOptions: ValidationOptions

    Returns PropertyDecorator

IsDefined

  • Checks if value is defined (!== undefined, !== null).

    Parameters

    Returns PropertyDecorator

IsDivisibleBy

  • IsDivisibleBy(num: number, validationOptions?: ValidationOptions): PropertyDecorator
  • Checks if value is a number that's divisible by another.

    Parameters

    Returns PropertyDecorator

IsEAN

  • Check if the string is an EAN (European Article Number). If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsEmail

  • IsEmail(options?: ValidatorJS.IsEmailOptions, validationOptions?: ValidationOptions): PropertyDecorator
  • Checks if the string is an email. If given value is not a string, then it returns false.

    Parameters

    • Optional options: ValidatorJS.IsEmailOptions
    • Optional validationOptions: ValidationOptions

    Returns PropertyDecorator

IsEmpty

  • Checks if given value is empty (=== '', === null, === undefined).

    Parameters

    Returns PropertyDecorator

IsEnum

  • Checks if a given value is an enum

    Parameters

    Returns PropertyDecorator

IsEthereumAddress

  • Check if the string is an Ethereum address using basic regex. Does not validate address checksums. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsFQDN

  • IsFQDN(options?: ValidatorJS.IsFQDNOptions, validationOptions?: ValidationOptions): PropertyDecorator
  • Checks if the string is a fully qualified domain name (e.g. domain.com). If given value is not a string, then it returns false.

    Parameters

    • Optional options: ValidatorJS.IsFQDNOptions
    • Optional validationOptions: ValidationOptions

    Returns PropertyDecorator

IsFirebasePushId

  • Checks if the string is a Firebase Push Id If given value is not a Firebase Push Id, it returns false

    Parameters

    Returns PropertyDecorator

IsFullWidth

  • Checks if the string contains any full-width chars. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsHSL

  • Check if the string is an HSL (hue, saturation, lightness, optional alpha) color based on CSS Colors Level 4 specification. Comma-separated format supported. Space-separated format supported with the exception of a few edge cases (ex: hsl(200grad+.1%62%/1)). If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsHalfWidth

  • Checks if the string contains any full-width chars. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsHash

  • IsHash(algorithm: string, validationOptions?: ValidationOptions): PropertyDecorator
  • Check if the string is a hash of type algorithm. Algorithm is one of ['md4', 'md5', 'sha1', 'sha256', 'sha384', 'sha512', 'ripemd128', 'ripemd160', 'tiger128', 'tiger160', 'tiger192', 'crc32', 'crc32b']

    Parameters

    Returns PropertyDecorator

IsHexColor

  • Checks if the string is a hexadecimal color. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsHexadecimal

  • Checks if the string is a hexadecimal number. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsIBAN

  • Check if a string is a IBAN (International Bank Account Number). If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsIP

  • Checks if the string is an IP (version 4 or 6). If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsISBN

  • Checks if the string is an ISBN (version 10 or 13). If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsISIN

  • Checks if the string is an ISIN (stock/security identifier). If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsISO31661Alpha2

  • Check if the string is a valid ISO 3166-1 alpha-2 officially assigned country code.

    Parameters

    Returns PropertyDecorator

IsISO31661Alpha3

  • Check if the string is a valid ISO 3166-1 alpha-3 officially assigned country code.

    Parameters

    Returns PropertyDecorator

IsISO8601

  • IsISO8601(options?: ValidatorJS.IsISO8601Options, validationOptions?: ValidationOptions): PropertyDecorator
  • Checks if the string is a valid ISO 8601 date. If given value is not a string, then it returns false. Use the option strict = true for additional checks for a valid date, e.g. invalidates dates like 2019-02-29.

    Parameters

    • Optional options: ValidatorJS.IsISO8601Options
    • Optional validationOptions: ValidationOptions

    Returns PropertyDecorator

IsISRC

  • Check if the string is a ISRC. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsISSN

  • IsISSN(options?: ValidatorJS.IsISSNOptions, validationOptions?: ValidationOptions): PropertyDecorator
  • Checks if the string is a ISSN. If given value is not a string, then it returns false.

    Parameters

    • Optional options: ValidatorJS.IsISSNOptions
    • Optional validationOptions: ValidationOptions

    Returns PropertyDecorator

IsIdentityCard

  • IsIdentityCard(locale?: ValidatorJS.IdentityCardLocale, validationOptions?: ValidationOptions): PropertyDecorator
  • Check if the string is a valid identity card code. locale is one of ['ES', 'zh-TW', 'he-IL', 'ar-TN'] OR 'any'. If 'any' is used, function will check if any of the locals match. Defaults to 'any'. If given value is not a string, then it returns false.

    Parameters

    • Optional locale: ValidatorJS.IdentityCardLocale
    • Optional validationOptions: ValidationOptions

    Returns PropertyDecorator

IsIn

  • IsIn(values: readonly any[], validationOptions?: ValidationOptions): PropertyDecorator
  • Checks if given value is in a array of allowed values.

    Parameters

    Returns PropertyDecorator

IsInstance

  • IsInstance(targetType: (...args: any[]) => any, validationOptions?: ValidationOptions): PropertyDecorator
  • Checks if the value is an instance of the specified object.

    Parameters

    • targetType: (...args: any[]) => any
        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    • Optional validationOptions: ValidationOptions

    Returns PropertyDecorator

IsInt

  • Checks if value is an integer.

    Parameters

    Returns PropertyDecorator

IsJSON

  • Checks if the string is valid JSON (note: uses JSON.parse). If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsJWT

  • Checks if the string is valid JWT token. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsLatLong

  • Checks if a value is string in format a "latitude,longitude".

    Parameters

    Returns PropertyDecorator

IsLatitude

  • Checks if a given value is a latitude.

    Parameters

    Returns PropertyDecorator

IsLocale

  • Check if the string is a locale. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsLongitude

  • Checks if a given value is a longitude.

    Parameters

    Returns PropertyDecorator

IsLowercase

  • Checks if the string is lowercase. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsMACAddress

  • IsMACAddress(optionsArg?: ValidatorJS.IsMACAddressOptions, validationOptionsArg?: ValidationOptions): PropertyDecorator
  • IsMACAddress(validationOptionsArg?: ValidationOptions): PropertyDecorator
  • Check if the string is a MAC address. If given value is not a string, then it returns false.

    Parameters

    • Optional optionsArg: ValidatorJS.IsMACAddressOptions
    • Optional validationOptionsArg: ValidationOptions

    Returns PropertyDecorator

  • Parameters

    Returns PropertyDecorator

IsMagnetURI

  • Check if the string is a magnet uri format. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsMilitaryTime

  • Checks if the string represents a time without a given timezone in the format HH:MM (military) If the given value does not match the pattern HH:MM, then it returns false.

    Parameters

    Returns PropertyDecorator

IsMimeType

  • Check if the string matches to a valid MIME type format If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsMobilePhone

  • IsMobilePhone(locale?: ValidatorJS.MobilePhoneLocale, options?: ValidatorJS.IsMobilePhoneOptions, validationOptions?: ValidationOptions): PropertyDecorator
  • Checks if the string is a mobile phone number (locale is either an array of locales (e.g ['sk-SK', 'sr-RS']) OR one of ['am-Am', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', ar-JO', 'ar-KW', 'ar-SA', 'ar-SY', 'ar-TN', 'be-BY', 'bg-BG', 'bn-BD', 'cs-CZ', 'da-DK', 'de-DE', 'de-AT', 'el-GR', 'en-AU', 'en-CA', 'en-GB', 'en-GG', 'en-GH', 'en-HK', 'en-MO', 'en-IE', 'en-IN', 'en-KE', 'en-MT', 'en-MU', 'en-NG', 'en-NZ', 'en-PK', 'en-RW', 'en-SG', 'en-SL', 'en-UG', 'en-US', 'en-TZ', 'en-ZA', 'en-ZM', 'es-CL', 'es-CR', 'es-EC', 'es-ES', 'es-MX', 'es-PA', 'es-PY', 'es-UY', 'et-EE', 'fa-IR', 'fi-FI', 'fj-FJ', 'fo-FO', 'fr-BE', 'fr-FR', 'fr-GF', 'fr-GP', 'fr-MQ', 'fr-RE', 'he-IL', 'hu-HU', 'id-ID', 'it-IT', 'ja-JP', 'kk-KZ', 'kl-GL', 'ko-KR', 'lt-LT', 'ms-MY', 'nb-NO', 'ne-NP', 'nl-BE', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ro-RO', 'ru-RU', 'sl-SI', 'sk-SK', 'sr-RS', 'sv-SE', 'th-TH', 'tr-TR', 'uk-UA', 'vi-VN', 'zh-CN', 'zh-HK', 'zh-MO', 'zh-TW'] If given value is not a string, then it returns false.

    Parameters

    • Optional locale: ValidatorJS.MobilePhoneLocale
    • Optional options: ValidatorJS.IsMobilePhoneOptions
    • Optional validationOptions: ValidationOptions

    Returns PropertyDecorator

IsMongoId

  • Checks if the string is a valid hex-encoded representation of a MongoDB ObjectId. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsMultibyte

  • Checks if the string contains one or more multibyte chars. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsNegative

  • Checks if the value is a negative number smaller than zero.

    Parameters

    Returns PropertyDecorator

IsNotEmpty

  • Checks if given value is not empty (!== '', !== null, !== undefined).

    Parameters

    Returns PropertyDecorator

IsNotEmptyObject

  • IsNotEmptyObject(options?: { nullable?: boolean }, validationOptions?: ValidationOptions): PropertyDecorator
  • Checks if the value is valid Object & not empty. Returns false if the value is not an object or an empty valid object.

    Parameters

    • Optional options: { nullable?: boolean }
      • Optional nullable?: boolean
    • Optional validationOptions: ValidationOptions

    Returns PropertyDecorator

IsNotIn

  • IsNotIn(values: readonly any[], validationOptions?: ValidationOptions): PropertyDecorator
  • Checks if given value not in a array of allowed values.

    Parameters

    Returns PropertyDecorator

IsNumber

  • Checks if a value is a number.

    Parameters

    Returns PropertyDecorator

IsNumberString

  • IsNumberString(options?: ValidatorJS.IsNumericOptions, validationOptions?: ValidationOptions): PropertyDecorator
  • Checks if the string is numeric. If given value is not a string, then it returns false.

    Parameters

    • Optional options: ValidatorJS.IsNumericOptions
    • Optional validationOptions: ValidationOptions

    Returns PropertyDecorator

IsObject

  • Checks if the value is valid Object. Returns false if the value is not an object.

    Parameters

    Returns PropertyDecorator

IsOctal

  • Check if the string is a valid octal number. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsOptional

  • Checks if value is missing and if so, ignores all validators.

    Parameters

    Returns PropertyDecorator

IsPassportNumber

  • IsPassportNumber(countryCode: string, validationOptions?: ValidationOptions): PropertyDecorator
  • Check if the string is a valid passport number relative to a specific country code. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsPhoneNumber

  • IsPhoneNumber(region?: CountryCode, validationOptions?: ValidationOptions): PropertyDecorator
  • Checks if the string is a valid phone number. To successfully validate any phone number the text must include the intl. calling code, if the calling code wont be provided then the region must be set.

    Parameters

    • Optional region: CountryCode

      2 characters uppercase country code (e.g. DE, US, CH) for country specific validation. If text doesn't start with the international calling code (e.g. +41), then you must set this parameter.

    • Optional validationOptions: ValidationOptions

    Returns PropertyDecorator

IsPort

  • Check if the string is a valid port number.

    Parameters

    Returns PropertyDecorator

IsPositive

  • Checks if the value is a positive number greater than zero.

    Parameters

    Returns PropertyDecorator

IsPostalCode

  • IsPostalCode(locale?: "any" | ValidatorJS.PostalCodeLocale, validationOptions?: ValidationOptions): PropertyDecorator
  • Check if the string is a postal code, (locale is one of [ 'AD', 'AT', 'AU', 'BE', 'BG', 'BR', 'CA', 'CH', 'CZ', 'DE', 'DK', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'ID', 'IE' 'IL', 'IN', 'IR', 'IS', 'IT', 'JP', 'KE', 'LI', 'LT', 'LU', 'LV', 'MT', 'MX', 'NL', 'NO', 'NZ', 'PL', 'PR', 'PT', 'RO', 'RU', 'SA', 'SE', 'SI', 'TN', 'TW', 'UA', 'US', 'ZA', 'ZM' ] OR 'any'. If 'any' is used, function will check if any of the locals match. Locale list is validator.isPostalCodeLocales.). If given value is not a string, then it returns false.

    Parameters

    • Optional locale: "any" | ValidatorJS.PostalCodeLocale
    • Optional validationOptions: ValidationOptions

    Returns PropertyDecorator

IsRFC3339

  • Check if the string is a valid RFC 3339 date. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsRgbColor

  • IsRgbColor(includePercentValues?: boolean, validationOptions?: ValidationOptions): PropertyDecorator
  • Check if the string is a rgb or rgba color. includePercentValues defaults to true. If you don't want to allow to set rgb or rgba values with percents, like rgb(5%,5%,5%), or rgba(90%,90%,90%,.3), then set it to false. If given value is not a string, then it returns false.

    Parameters

    • Optional includePercentValues: boolean
    • Optional validationOptions: ValidationOptions

    Returns PropertyDecorator

IsSemVer

  • Check if the string is a Semantic Versioning Specification (SemVer). If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsString

  • Checks if a given value is a real string.

    Parameters

    Returns PropertyDecorator

IsSurrogatePair

  • Checks if the string contains any surrogate pairs chars. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsUUID

  • Checks if the string is a UUID (version 3, 4 or 5). If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsUppercase

  • Checks if the string is uppercase. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

IsUrl

  • IsUrl(options?: ValidatorJS.IsURLOptions, validationOptions?: ValidationOptions): PropertyDecorator
  • Checks if the string is an url. If given value is not a string, then it returns false.

    Parameters

    • Optional options: ValidatorJS.IsURLOptions
    • Optional validationOptions: ValidationOptions

    Returns PropertyDecorator

IsVariableWidth

  • Checks if the string contains variable-width chars. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

Length

  • Length(min: number, max?: number, validationOptions?: ValidationOptions): PropertyDecorator
  • Checks if the string's length falls in a range. Note: this function takes into account surrogate pairs. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

Matches

  • Matches(pattern: RegExp, validationOptions?: ValidationOptions): PropertyDecorator
  • Matches(pattern: string, modifiers?: string, validationOptions?: ValidationOptions): PropertyDecorator
  • Checks if string matches the pattern. Either matches('foo', /foo/i) If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

  • Parameters

    • pattern: string
    • Optional modifiers: string
    • Optional validationOptions: ValidationOptions

    Returns PropertyDecorator

Max

  • Checks if the first number is less than or equal to the second.

    Parameters

    Returns PropertyDecorator

MaxDate

  • Checks if the value is a date that's after the specified date.

    Parameters

    Returns PropertyDecorator

MaxLength

  • Checks if the string's length is not more than given number. Note: this function takes into account surrogate pairs. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

Min

  • Checks if the first number is greater than or equal to the second.

    Parameters

    Returns PropertyDecorator

MinDate

  • Checks if the value is a date that's after the specified date.

    Parameters

    Returns PropertyDecorator

MinLength

  • Checks if the string's length is not less than given number. Note: this function takes into account surrogate pairs. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

NotContains

  • NotContains(seed: string, validationOptions?: ValidationOptions): PropertyDecorator
  • Checks if the string does not contain the seed. If given value is not a string, then it returns false.

    Parameters

    Returns PropertyDecorator

NotEquals

  • NotEquals(comparison: any, validationOptions?: ValidationOptions): PropertyDecorator
  • Checks if value does not match ("!==") the comparison.

    Parameters

    Returns PropertyDecorator

Validate

  • Validate(constraintClass: Function, validationOptions?: ValidationOptions): PropertyDecorator
  • Validate(constraintClass: Function, constraints?: any[], validationOptions?: ValidationOptions): PropertyDecorator
  • Performs validation based on the given custom validation class. Validation class must be decorated with ValidatorConstraint decorator.

    Parameters

    Returns PropertyDecorator

  • Parameters

    • constraintClass: Function
    • Optional constraints: any[]
    • Optional validationOptions: ValidationOptions

    Returns PropertyDecorator

ValidateBy

  • Parameters

    Returns PropertyDecorator

ValidateIf

  • ValidateIf(condition: (object: any, value: any) => boolean, validationOptions?: ValidationOptions): PropertyDecorator
  • Ignores the other validators on a property when the provided condition function returns false.

    Parameters

    • condition: (object: any, value: any) => boolean
        • (object: any, value: any): boolean
        • Parameters

          • object: any
          • value: any

          Returns boolean

    • Optional validationOptions: ValidationOptions

    Returns PropertyDecorator

ValidateNested

  • Objects / object arrays marked with this decorator will also be validated.

    Parameters

    Returns PropertyDecorator

ValidatePromise

  • Resolve promise before validation

    Parameters

    Returns PropertyDecorator

ValidatorConstraint

  • ValidatorConstraint(options?: { async?: boolean; name?: string }): (target: Function) => void
  • Registers custom validator class.

    Parameters

    • Optional options: { async?: boolean; name?: string }
      • Optional async?: boolean
      • Optional name?: string

    Returns (target: Function) => void

      • (target: Function): void
      • Parameters

        • target: Function

        Returns void

arrayContains

  • arrayContains(array: unknown, values: any[]): boolean
  • Checks if array contains all values from the given array of values. If null or undefined is given then this function returns false.

    Parameters

    • array: unknown
    • values: any[]

    Returns boolean

arrayMaxSize

  • arrayMaxSize(array: unknown, max: number): boolean
  • Checks if the array's length is less or equal to the specified number. If null or undefined is given then this function returns false.

    Parameters

    • array: unknown
    • max: number

    Returns boolean

arrayMinSize

  • arrayMinSize(array: unknown, min: number): boolean
  • Checks if the array's length is greater than or equal to the specified number. If null or undefined is given then this function returns false.

    Parameters

    • array: unknown
    • min: number

    Returns boolean

arrayNotContains

  • arrayNotContains(array: unknown, values: any[]): boolean
  • Checks if array does not contain any of the given values. If null or undefined is given then this function returns false.

    Parameters

    • array: unknown
    • values: any[]

    Returns boolean

arrayNotEmpty

  • arrayNotEmpty(array: unknown): boolean
  • Checks if given array is not empty. If null or undefined is given then this function returns false.

    Parameters

    • array: unknown

    Returns boolean

arrayUnique

  • Checks if all array's values are unique. Comparison for objects is reference-based. If null or undefined is given then this function returns false.

    Parameters

    Returns boolean

buildMessage

clearValidationErrorHandler

  • clearValidationErrorHandler(): void

contains

  • contains(value: unknown, seed: string): boolean
  • Checks if the string contains the seed. If given value is not a string, then it returns false.

    Parameters

    • value: unknown
    • seed: string

    Returns boolean

equals

  • equals(value: unknown, comparison: unknown): boolean
  • Checks if value matches ("===") the comparison.

    Parameters

    • value: unknown
    • comparison: unknown

    Returns boolean

getFromContainer

  • getFromContainer<T>(someClass: {} | Function): T
  • Gets the IOC container used by this library.

    Type parameters

    • T

    Parameters

    • someClass: {} | Function

    Returns T

getMetadataStorage

  • Gets metadata storage. Metadata storage follows the best practices and stores metadata in a global variable.

    Returns MetadataStorage

getValidationErrorMap

  • Receives an array of ValidationError, and generates an object with key-value pairs where the keys represent a property name, and the values are an array of all validation error messages for that property.

    Parameters

    • errors: ValidationError[]

      The array of ValidationError to generate a validation error map from.

    Returns ValidationErrorMap

isAlpha

  • isAlpha(value: unknown, locale?: ValidatorJS.AlphaLocale): boolean
  • Checks if the string contains only letters (a-zA-Z). If given value is not a string, then it returns false.

    Parameters

    • value: unknown
    • Optional locale: ValidatorJS.AlphaLocale

    Returns boolean

isAlphanumeric

  • isAlphanumeric(value: unknown, locale?: ValidatorJS.AlphanumericLocale): boolean
  • Checks if the string contains only letters and numbers. If given value is not a string, then it returns false.

    Parameters

    • value: unknown
    • Optional locale: ValidatorJS.AlphanumericLocale

    Returns boolean

isArray

  • isArray(value: unknown): boolean
  • Checks if a given value is an array

    Parameters

    • value: unknown

    Returns boolean

isAscii

  • isAscii(value: unknown): boolean
  • Checks if the string contains ASCII chars only. If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isBIC

  • isBIC(value: unknown): boolean
  • Check if a string is a BIC (Bank Identification Code) or SWIFT code. If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isBase32

  • isBase32(value: unknown): boolean
  • Checks if a string is base32 encoded. If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isBase64

  • isBase64(value: unknown): boolean
  • Checks if a string is base64 encoded. If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isBoolean

  • isBoolean(value: unknown): boolean
  • Checks if a given value is a boolean.

    Parameters

    • value: unknown

    Returns boolean

isBooleanString

  • isBooleanString(value: unknown): boolean
  • Checks if a string is a boolean. If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isBtcAddress

  • isBtcAddress(value: unknown): boolean
  • Check if the string is a valid BTC address. If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isByteLength

  • isByteLength(value: unknown, min: number, max?: number): boolean
  • Checks if the string's length (in bytes) falls in a range. If given value is not a string, then it returns false.

    Parameters

    • value: unknown
    • min: number
    • Optional max: number

    Returns boolean

isCreditCard

  • isCreditCard(value: unknown): boolean
  • Checks if the string is a credit card. If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isCurrency

  • isCurrency(value: unknown, options?: ValidatorJS.IsCurrencyOptions): boolean
  • Checks if the string is a valid currency amount. If given value is not a string, then it returns false.

    Parameters

    • value: unknown
    • Optional options: ValidatorJS.IsCurrencyOptions

    Returns boolean

isDataURI

  • isDataURI(value: unknown): boolean
  • Check if the string is a data uri format. If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isDate

  • isDate(value: unknown): boolean
  • Checks if a given value is a date.

    Parameters

    • value: unknown

    Returns boolean

isDateString

  • isDateString(value: unknown, options?: ValidatorJS.IsISO8601Options): boolean
  • Alias for IsISO8601 validator

    Parameters

    • value: unknown
    • Optional options: ValidatorJS.IsISO8601Options

    Returns boolean

isDecimal

  • isDecimal(value: unknown, options?: ValidatorJS.IsDecimalOptions): boolean
  • Checks if the string is a valid decimal. If given value is not a string, then it returns false.

    Parameters

    • value: unknown
    • Optional options: ValidatorJS.IsDecimalOptions

    Returns boolean

isDefined

  • isDefined(value: any): boolean
  • Checks if value is defined (!== undefined, !== null).

    Parameters

    • value: any

    Returns boolean

isDivisibleBy

  • isDivisibleBy(value: unknown, num: number): boolean
  • Checks if value is a number that's divisible by another.

    Parameters

    • value: unknown
    • num: number

    Returns boolean

isEAN

  • isEAN(value: unknown): boolean
  • Check if the string is an EAN (European Article Number). If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isEmail

  • isEmail(value: unknown, options?: ValidatorJS.IsEmailOptions): boolean
  • Checks if the string is an email. If given value is not a string, then it returns false.

    Parameters

    • value: unknown
    • Optional options: ValidatorJS.IsEmailOptions

    Returns boolean

isEmpty

  • isEmpty(value: unknown): boolean
  • Checks if given value is empty (=== '', === null, === undefined).

    Parameters

    • value: unknown

    Returns boolean

isEnum

  • isEnum(value: unknown, entity: any): boolean
  • Checks if a given value is an enum

    Parameters

    • value: unknown
    • entity: any

    Returns boolean

isEthereumAddress

  • isEthereumAddress(value: unknown): boolean
  • Check if the string is an Ethereum address using basic regex. Does not validate address checksums. If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isFQDN

  • isFQDN(value: unknown, options?: ValidatorJS.IsFQDNOptions): boolean
  • Checks if the string is a fully qualified domain name (e.g. domain.com). If given value is not a string, then it returns false.

    Parameters

    • value: unknown
    • Optional options: ValidatorJS.IsFQDNOptions

    Returns boolean

isFirebasePushId

  • isFirebasePushId(value: unknown): boolean
  • Checks if the string is a Firebase Push Id If given value is not a Firebase Push Id, it returns false

    Parameters

    • value: unknown

    Returns boolean

isFullWidth

  • isFullWidth(value: unknown): boolean
  • Checks if the string contains any full-width chars. If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isHSL

  • isHSL(value: unknown): boolean
  • Check if the string is an HSL (hue, saturation, lightness, optional alpha) color based on CSS Colors Level 4 specification. Comma-separated format supported. Space-separated format supported with the exception of a few edge cases (ex: hsl(200grad+.1%62%/1)). If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isHalfWidth

  • isHalfWidth(value: unknown): boolean
  • Checks if the string contains any half-width chars. If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isHash

  • isHash(value: unknown, algorithm: ValidatorJS.HashAlgorithm): boolean
  • Check if the string is a hash of type algorithm. Algorithm is one of ['md4', 'md5', 'sha1', 'sha256', 'sha384', 'sha512', 'ripemd128', 'ripemd160', 'tiger128', 'tiger160', 'tiger192', 'crc32', 'crc32b']

    Parameters

    • value: unknown
    • algorithm: ValidatorJS.HashAlgorithm

    Returns boolean

isHexColor

  • isHexColor(value: unknown): boolean
  • Checks if the string is a hexadecimal color. If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isHexadecimal

  • isHexadecimal(value: unknown): boolean
  • Checks if the string is a hexadecimal number. If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isIBAN

  • isIBAN(value: unknown): boolean
  • Check if a string is a IBAN (International Bank Account Number). If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isIP

  • Checks if the string is an IP (version 4 or 6). If given value is not a string, then it returns false.

    Parameters

    Returns boolean

isISBN

  • Checks if the string is an ISBN (version 10 or 13). If given value is not a string, then it returns false.

    Parameters

    Returns boolean

isISIN

  • isISIN(value: unknown): boolean
  • Checks if the string is an ISIN (stock/security identifier). If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isISO31661Alpha2

  • isISO31661Alpha2(value: unknown): boolean
  • Check if the string is a valid ISO 3166-1 alpha-2 officially assigned country code.

    Parameters

    • value: unknown

    Returns boolean

isISO31661Alpha3

  • isISO31661Alpha3(value: unknown): boolean
  • Check if the string is a valid ISO 3166-1 alpha-3 officially assigned country code.

    Parameters

    • value: unknown

    Returns boolean

isISO8601

  • isISO8601(value: unknown, options?: ValidatorJS.IsISO8601Options): boolean
  • Checks if the string is a valid ISO 8601 date. If given value is not a string, then it returns false. Use the option strict = true for additional checks for a valid date, e.g. invalidates dates like 2019-02-29.

    Parameters

    • value: unknown
    • Optional options: ValidatorJS.IsISO8601Options

    Returns boolean

isISRC

  • isISRC(value: unknown): boolean
  • Check if the string is a ISRC. If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isISSN

  • isISSN(value: unknown, options?: ValidatorJS.IsISSNOptions): boolean
  • Checks if the string is a ISSN. If given value is not a string, then it returns false.

    Parameters

    • value: unknown
    • Optional options: ValidatorJS.IsISSNOptions

    Returns boolean

isIdentityCard

  • isIdentityCard(value: unknown, locale: ValidatorJS.IdentityCardLocale): boolean
  • Check if the string is a valid identity card code. locale is one of ['ES', 'zh-TW', 'he-IL', 'ar-TN'] OR 'any'. If 'any' is used, function will check if any of the locals match. Defaults to 'any'. If given value is not a string, then it returns false.

    Parameters

    • value: unknown
    • locale: ValidatorJS.IdentityCardLocale

    Returns boolean

isIn

  • isIn(value: unknown, possibleValues: readonly unknown[]): boolean
  • Checks if given value is in a array of allowed values.

    Parameters

    • value: unknown
    • possibleValues: readonly unknown[]

    Returns boolean

isInstance

  • isInstance(object: unknown, targetTypeConstructor: (...args: any[]) => any): boolean
  • Checks if the value is an instance of the specified object.

    Parameters

    • object: unknown
    • targetTypeConstructor: (...args: any[]) => any
        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    Returns boolean

isInt

  • isInt(val: unknown): boolean
  • Checks if value is an integer.

    Parameters

    • val: unknown

    Returns boolean

isJSON

  • isJSON(value: unknown): boolean
  • Checks if the string is valid JSON (note: uses JSON.parse). If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isJWT

  • isJWT(value: unknown): boolean
  • Checks if the string is valid JWT token. If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isLatLong

  • isLatLong(value: string): boolean
  • Checks if a value is string in format a "latitude,longitude".

    Parameters

    • value: string

    Returns boolean

isLatitude

  • isLatitude(value: string): boolean
  • Checks if a given value is a latitude.

    Parameters

    • value: string

    Returns boolean

isLocale

  • isLocale(value: unknown): boolean
  • Check if the string is a locale. If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isLongitude

  • isLongitude(value: string): boolean
  • Checks if a given value is a longitude.

    Parameters

    • value: string

    Returns boolean

isLowercase

  • isLowercase(value: unknown): boolean
  • Checks if the string is lowercase. If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isMACAddress

  • isMACAddress(value: unknown, options?: ValidatorJS.IsMACAddressOptions): boolean
  • Check if the string is a MAC address. If given value is not a string, then it returns false.

    Parameters

    • value: unknown
    • Optional options: ValidatorJS.IsMACAddressOptions

    Returns boolean

isMagnetURI

  • isMagnetURI(value: unknown): boolean
  • Check if the string is a magnet uri format. If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isMilitaryTime

  • isMilitaryTime(value: unknown): boolean
  • Checks if the string represents a time without a given timezone in the format HH:MM (military) If the given value does not match the pattern HH:MM, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isMimeType

  • isMimeType(value: unknown): boolean
  • Check if the string matches to a valid MIME type format If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isMobilePhone

  • isMobilePhone(value: unknown, locale?: ValidatorJS.MobilePhoneLocale, options?: ValidatorJS.IsMobilePhoneOptions): boolean
  • Checks if the string is a mobile phone number (locale is either an array of locales (e.g ['sk-SK', 'sr-RS']) OR one of ['am-Am', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', ar-JO', 'ar-KW', 'ar-SA', 'ar-SY', 'ar-TN', 'be-BY', 'bg-BG', 'bn-BD', 'cs-CZ', 'da-DK', 'de-DE', 'de-AT', 'el-GR', 'en-AU', 'en-CA', 'en-GB', 'en-GG', 'en-GH', 'en-HK', 'en-MO', 'en-IE', 'en-IN', 'en-KE', 'en-MT', 'en-MU', 'en-NG', 'en-NZ', 'en-PK', 'en-RW', 'en-SG', 'en-SL', 'en-UG', 'en-US', 'en-TZ', 'en-ZA', 'en-ZM', 'es-CL', 'es-CR', 'es-EC', 'es-ES', 'es-MX', 'es-PA', 'es-PY', 'es-UY', 'et-EE', 'fa-IR', 'fi-FI', 'fj-FJ', 'fo-FO', 'fr-BE', 'fr-FR', 'fr-GF', 'fr-GP', 'fr-MQ', 'fr-RE', 'he-IL', 'hu-HU', 'id-ID', 'it-IT', 'ja-JP', 'kk-KZ', 'kl-GL', 'ko-KR', 'lt-LT', 'ms-MY', 'nb-NO', 'ne-NP', 'nl-BE', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ro-RO', 'ru-RU', 'sl-SI', 'sk-SK', 'sr-RS', 'sv-SE', 'th-TH', 'tr-TR', 'uk-UA', 'vi-VN', 'zh-CN', 'zh-HK', 'zh-MO', 'zh-TW'] If given value is not a string, then it returns false.

    Parameters

    • value: unknown
    • Optional locale: ValidatorJS.MobilePhoneLocale
    • Optional options: ValidatorJS.IsMobilePhoneOptions

    Returns boolean

isMongoId

  • isMongoId(value: unknown): boolean
  • Checks if the string is a valid hex-encoded representation of a MongoDB ObjectId. If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isMultibyte

  • isMultibyte(value: unknown): boolean
  • Checks if the string contains one or more multibyte chars. If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isNegative

  • isNegative(value: unknown): boolean
  • Checks if the value is a negative number smaller than zero.

    Parameters

    • value: unknown

    Returns boolean

isNotEmpty

  • isNotEmpty(value: unknown): boolean
  • Checks if given value is not empty (!== '', !== null, !== undefined).

    Parameters

    • value: unknown

    Returns boolean

isNotEmptyObject

  • isNotEmptyObject(value: unknown, options?: { nullable?: boolean }): boolean
  • Checks if the value is valid Object & not empty. Returns false if the value is not an object or an empty valid object.

    Parameters

    • value: unknown
    • Optional options: { nullable?: boolean }
      • Optional nullable?: boolean

    Returns boolean

isNotIn

  • isNotIn(value: unknown, possibleValues: readonly unknown[]): boolean
  • Checks if given value not in a array of allowed values.

    Parameters

    • value: unknown
    • possibleValues: readonly unknown[]

    Returns boolean

isNumber

  • Checks if a given value is a number.

    Parameters

    Returns boolean

isNumberString

  • isNumberString(value: unknown, options?: ValidatorJS.IsNumericOptions): boolean
  • Checks if the string is numeric. If given value is not a string, then it returns false.

    Parameters

    • value: unknown
    • Optional options: ValidatorJS.IsNumericOptions

    Returns boolean

isObject

  • isObject(value: unknown): value is object
  • Checks if the value is valid Object. Returns false if the value is not an object.

    Parameters

    • value: unknown

    Returns value is object

isOctal

  • isOctal(value: unknown): boolean
  • Check if the string is a valid octal number. If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isPassportNumber

  • isPassportNumber(value: unknown, countryCode: string): boolean
  • Check if the string is a valid passport number relative to a specific country code. If given value is not a string, then it returns false.

    Parameters

    • value: unknown
    • countryCode: string

    Returns boolean

isPhoneNumber

  • isPhoneNumber(value: string, region?: CountryCode): boolean
  • Checks if the string is a valid phone number. To successfully validate any phone number the text must include the intl. calling code, if the calling code wont be provided then the region must be set.

    Parameters

    • value: string

      the potential phone number string to test

    • Optional region: CountryCode

      2 characters uppercase country code (e.g. DE, US, CH) for country specific validation. If text doesn't start with the international calling code (e.g. +41), then you must set this parameter.

    Returns boolean

isPort

  • isPort(value: unknown): boolean
  • Check if the string is a valid port number.

    Parameters

    • value: unknown

    Returns boolean

isPositive

  • isPositive(value: unknown): boolean
  • Checks if the value is a positive number greater than zero.

    Parameters

    • value: unknown

    Returns boolean

isPostalCode

  • isPostalCode(value: unknown, locale: "any" | ValidatorJS.PostalCodeLocale): boolean
  • Check if the string is a postal code, (locale is one of [ 'AD', 'AT', 'AU', 'BE', 'BG', 'BR', 'CA', 'CH', 'CZ', 'DE', 'DK', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'ID', 'IE' 'IL', 'IN', 'IR', 'IS', 'IT', 'JP', 'KE', 'LI', 'LT', 'LU', 'LV', 'MT', 'MX', 'NL', 'NO', 'NZ', 'PL', 'PR', 'PT', 'RO', 'RU', 'SA', 'SE', 'SI', 'TN', 'TW', 'UA', 'US', 'ZA', 'ZM' ] OR 'any'. If 'any' is used, function will check if any of the locals match. Locale list is validator.isPostalCodeLocales.). If given value is not a string, then it returns false.

    Parameters

    • value: unknown
    • locale: "any" | ValidatorJS.PostalCodeLocale

    Returns boolean

isRFC3339

  • isRFC3339(value: unknown): boolean
  • Check if the string is a valid RFC 3339 date. If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isRgbColor

  • isRgbColor(value: unknown, includePercentValues?: boolean): boolean
  • Check if the string is a rgb or rgba color. includePercentValues defaults to true. If you don't want to allow to set rgb or rgba values with percents, like rgb(5%,5%,5%), or rgba(90%,90%,90%,.3), then set it to false. If given value is not a string, then it returns false.

    Parameters

    • value: unknown
    • Optional includePercentValues: boolean

    Returns boolean

isSemVer

  • isSemVer(value: unknown): boolean
  • Check if the string is a Semantic Versioning Specification (SemVer). If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isString

  • isString(value: unknown): value is string
  • Checks if a given value is a real string.

    Parameters

    • value: unknown

    Returns value is string

isSurrogatePair

  • isSurrogatePair(value: unknown): boolean
  • Checks if the string contains any surrogate pairs chars. If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isURL

  • isURL(value: string, options?: ValidatorJS.IsURLOptions): boolean
  • Checks if the string is an url. If given value is not a string, then it returns false.

    Parameters

    • value: string
    • Optional options: ValidatorJS.IsURLOptions

    Returns boolean

isUUID

  • isUUID(value: unknown, version?: UUIDVersion): boolean
  • Checks if the string is a UUID (version 3, 4 or 5). If given value is not a string, then it returns false.

    Parameters

    Returns boolean

isUppercase

  • isUppercase(value: unknown): boolean
  • Checks if the string is uppercase. If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

isValidationOptions

  • Parameters

    • val: any

    Returns val is ValidationOptions

isVariableWidth

  • isVariableWidth(value: unknown): boolean
  • Checks if the string contains variable-width chars. If given value is not a string, then it returns false.

    Parameters

    • value: unknown

    Returns boolean

length

  • length(value: unknown, min: number, max?: number): boolean
  • Checks if the string's length falls in a range. Note: this function takes into account surrogate pairs. If given value is not a string, then it returns false.

    Parameters

    • value: unknown
    • min: number
    • Optional max: number

    Returns boolean

matches

  • matches(value: string, pattern: RegExp): boolean
  • matches(value: string, pattern: string, modifiers: string): boolean
  • Checks if string matches the pattern. Either matches('foo', /foo/i). If given value is not a string, then it returns false.

    Parameters

    • value: string
    • pattern: RegExp

    Returns boolean

  • Parameters

    • value: string
    • pattern: string
    • modifiers: string

    Returns boolean

max

  • max(num: unknown, max: number): boolean
  • Checks if the first number is less than or equal to the second.

    Parameters

    • num: unknown
    • max: number

    Returns boolean

maxDate

  • maxDate(date: unknown, maxDate: Date): boolean
  • Checks if the value is a date that's before the specified date.

    Parameters

    • date: unknown
    • maxDate: Date

    Returns boolean

maxLength

  • maxLength(value: unknown, max: number): boolean
  • Checks if the string's length is not more than given number. Note: this function takes into account surrogate pairs. If given value is not a string, then it returns false.

    Parameters

    • value: unknown
    • max: number

    Returns boolean

min

  • min(num: unknown, min: number): boolean
  • Checks if the first number is greater than or equal to the second.

    Parameters

    • num: unknown
    • min: number

    Returns boolean

minDate

  • minDate(date: unknown, minDate: Date): boolean
  • Checks if the value is a date that's after the specified date.

    Parameters

    • date: unknown
    • minDate: Date

    Returns boolean

minLength

  • minLength(value: unknown, min: number): boolean
  • Checks if the string's length is not less than given number. Note: this function takes into account surrogate pairs. If given value is not a string, then it returns false.

    Parameters

    • value: unknown
    • min: number

    Returns boolean

notContains

  • notContains(value: unknown, seed: string): boolean
  • Checks if the string does not contain the seed. If given value is not a string, then it returns false.

    Parameters

    • value: unknown
    • seed: string

    Returns boolean

notEquals

  • notEquals(value: unknown, comparison: unknown): boolean
  • Checks if value does not match ("!==") the comparison.

    Parameters

    • value: unknown
    • comparison: unknown

    Returns boolean

registerDecorator

  • Registers a custom validation decorator.

    Parameters

    Returns void

registerSchema

  • Registers a new validation schema.

    Parameters

    Returns void

setValidationErrorHandler

useContainer

  • Sets container to be used by this library.

    Parameters

    • iocContainer: { get: any }
      • get: function
        • get(someClass: any): any
        • Parameters

          • someClass: any

          Returns any

    • Optional options: UseContainerOptions

    Returns void

validate

  • Validates given object.

    Parameters

    Returns Promise<ValidationError[]>

  • Validates given object by a given validation schema.

    Parameters

    Returns Promise<ValidationError[]>

validateOrReject

  • validateOrReject(object: object, validatorOptions?: ValidatorOptions): Promise<void>
  • validateOrReject(schemaName: string, object: object, validatorOptions?: ValidatorOptions): Promise<void>
  • Validates given object and reject on error.

    Parameters

    Returns Promise<void>

  • Validates given object by a given validation schema and reject on error.

    Parameters

    Returns Promise<void>

validateSync

  • Performs sync validation of the given object. Note that this method completely ignores async validations. If you want to properly perform validation you need to call validate method instead.

    Parameters

    Returns ValidationError[]

  • Validates given object by a given validation schema. Note that this method completely ignores async validations. If you want to properly perform validation you need to call validate method instead.

    Parameters

    Returns ValidationError[]

Generated using TypeDoc