Options
All
  • Public
  • Public/Protected
  • All
Menu

Runtime data validation for TypeScript - v0.2.2

These are the validation decorators for the runtime-data-validation package. The functions in this module are actually decorators, but the documentation is unable to present them as decorators.

For the functions we've categorized as decorators, the API will be described something like this:

IsAlpha(locale?: string, options?: IsAlphaOptions):
(target: Object, propertyKey?: string | symbol,
descriptor?: number | PropertyDescriptor) => void

This is the @IsAlpha() decorator. This decorator takes two ptional parameters, locale and options. Any parameters shown are where you should focus your attention. The return type shown here is the decorator function, which you should ignore since it is an implementation detail of TypeScript decorators.

In other words, the usage is:

class Example {
#title: string;

@ValidateAccessor<string>()
@IsAlpha('en-US')
set title(ny: string) { this.#title = ny; }
get title() { return this.#title; }
}

In other words, coding this as a decorator we use @DecoratorName() and do not pay attention to the decorator function return value.

Return to home page

Index

Validation Decorator

  • Contains(seed: string, options?: ContainsOptions): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Parameters

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • Equals(comparison: string): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Parameters

    • comparison: string

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsAlpha(locale?: string, options?: IsAlphaOptions): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Parameters

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsAlphanumeric(locale?: string, options?: IsAlphaOptions): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Parameters

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsAscii(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsBase32(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsBase58(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsBase64(options?: IsBase64Options): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Parameters

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsBoolean(options?: IsBooleanOptions): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Parameters

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsBtcAddress(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Check if the string is a valid BTC address.

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsByteLength(options?: IsByteLengthOptions): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Parameters

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsCreditCard(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsDataURI(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsDate(options?: IsDateOptions): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Parameters

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsDecimal(options?: IsDecimalOptions): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Parameters

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsEAN(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsEmail(options?: IsEmailOptions): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Parameters

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsEmpty(options?: IsEmptyOptions): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Parameters

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsEthereumAddress(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Check if the string is an Ethereum address using basic regex. Does not validate address checksums.

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsFQDN(options?: IsFQDNOptions): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Parameters

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsFloat(options?: IsFloatOptions): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Parameters

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsFloatRange(min: number, max: number): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Parameters

    • min: number
    • max: number

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsFullWidth(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsHSL(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsHalfWidth(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsHash(algorithm: string): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • check if the string is a hash of type algorithm.

    Parameters

    • algorithm: string

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsHexColor(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsHexadecimal(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsIBAN(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsIMEI(options?: IsIMEIOptions): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Parameters

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsIP(version?: number): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Parameters

    • Optional version: number

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsIPRange(version?: number): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Parameters

    • Optional version: number

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsISBN(version?: number): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Parameters

    • Optional version: number

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsISIN(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsISO31661Alpha2(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Check if the string is a valid ISO 3166-1 alpha-2 officially assigned country code.

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsISO31661Alpha3(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Check if the string is a valid ISO 3166-1 alpha-3 officially assigned country code.

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsISO4217(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Check if the string is a valid ISO 4217 officially assigned currency code.

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsISO8601(options?: IsISO8601Options): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Check if the string is a valid ISO 8601 date.

    Parameters

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsISRC(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Check if the string is an International Standard Recording Code (ISRC). https://en.wikipedia.org/wiki/International_Standard_Recording_Code

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsISSN(options?: isISSNOptions): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Check if the string is an International Standard Serial Number (ISSN). https://en.wikipedia.org/wiki/International_Standard_Serial_Number

    Parameters

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsIdentityCard(locale?: string): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Parameters

    • Optional locale: string

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsIn(values: string[]): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Parameters

    • values: string[]

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsInt(options?: IsIntOptions): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Parameters

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsIntRange(min: number, max: number): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Parameters

    • min: number
    • max: number

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsJSON(options?: isJSONOptions): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Parameters

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsJWT(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Check if the string is valid JWT token.

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsLatLong(options?: isLatLongOptions): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • check if the string is a valid latitude-longitude coordinate in the format lat,long or lat, long.

    Parameters

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsLength(options?: isLengthOptions): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • check if the string's length falls in a range.

    Parameters

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsLicensePlate(locale?: string): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • check if string matches the format of a country's license plate.

    Parameters

    • Optional locale: string

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsLocale(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • check if the string is a locale

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsLowercase(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • check if the string is lowercase.

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsMACAddress(options?: isMACAddressOptions): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Parameters

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsMD5(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • check if the string is a hash of type algorithm.

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsMagnetURI(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Check if the string is valid JWT token.

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsMimeType(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • check if the string matches to a valid MIME type format https://en.wikipedia.org/wiki/Media_type

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsMobilePhone(locale?: string, options?: isMobilePhoneOptions): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • check if the string is a mobile phone number,

    Parameters

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsMongoId(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • check if the string is a valid hex-encoded representation of a MongoDB ObjectId. http://docs.mongodb.org/manual/reference/object-id/

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsMultibyte(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • check if the string contains one or more multibyte chars.

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsNumeric(options?: isNumericOptions): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • check if the string contains only numbers.

    Parameters

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsOctal(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • check if the string is a valid octal number.

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsPassportNumber(countryCode?: string): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • check if the string is a valid passport number.

    Parameters

    • Optional countryCode: string

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsPort(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • check if the string is a valid port number.

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsRFC3339(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • check if the string is a valid RFC 3339 date. https://tools.ietf.org/html/rfc3339

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsRgbColor(includePercentValues?: boolean): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • check if the string is a rgb or rgba color.

    Parameters

    • Optional includePercentValues: boolean

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsSemVer(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • check if the string is a Semantic Versioning Specification (SemVer).

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsSlug(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Check if the string is of type slug.

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsStrongPassword(options?: isStrongPasswordOptions): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Check if a password is strong or not. Allows for custom requirements or scoring rules. The returnScore option is silently ignored because it is not compatible with a validation decorator.

    Parameters

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsSurrogatePair(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • check if the string contains any surrogate pairs chars.

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsTaxID(locale?: string): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Check if the given value is a valid Tax Identification Number. Default locale is en-US.

    Parameters

    • Optional locale: string

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsURL(options?: isURLOptions): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • check if the string is an URL.

    Parameters

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsUUID(version?: number): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • check if the string is a UUID (version 1, 2, 3, 4 or 5).

    Parameters

    • Optional version: number

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsUppercase(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • check if the string is uppercase.

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsVAT(countryCode: string): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • IsVariableWidth(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • check if the string contains a mixture of full and half-width chars.

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • IsWhitelisted(chars: string): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • checks characters if they appear in the whitelist.

    Parameters

    • chars: string

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • matches(pattern: string | RegExp, modifiers?: string): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • check if string matches the pattern.

    Either matches('foo', /foo/i) or matches('foo', 'foo', 'i').

    Parameters

    • pattern: string | RegExp
    • Optional modifiers: string

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

Decorator Generator

  • generateValidationDecorator(validator: Function, message: string): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Generates either an accessor validation decorator function, or parameter validation decorator function, depending on the context in which it is being used. The validator parameter must be a function for data validation, which returns true if the data is valid, or false otherwise. The function data is stored in reflection metadata, which is used by ValidateAccessor or ValidateParams to drive the validation process.

    Parameters

    • validator: Function

      The validation function

    • message: string

      The error message to use in thrown exceptions

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

Execution Decorator

  • ValidateAccessor<T>(): ((target: Object, propertyKey: string, descriptor: PropertyDescriptor) => void)
  • An accessor decorator function which performs data validation according to the validation decorators attached to the accessor.

    Type Parameters

    • T

    Returns ((target: Object, propertyKey: string, descriptor: PropertyDescriptor) => void)

      • (target: Object, propertyKey: string, descriptor: PropertyDescriptor): void
      • Parameters

        • target: Object
        • propertyKey: string
        • descriptor: PropertyDescriptor

        Returns void

  • ValidateParams(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void
  • A method decorator function which performs data validation according to the validation decorators attached to any method parameters.

    Parameters

    • target: Object
    • propertyKey: string | symbol
    • descriptor: PropertyDescriptor

    Returns void

Other

  • IsISO8601Duration(): ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)
  • Check if the string is a valid ISO 8601 Duration string.

    Returns ((target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor) => void)

      • (target: Object, propertyKey?: string | symbol, descriptor?: number | PropertyDescriptor): void
      • Parameters

        • target: Object
        • Optional propertyKey: string | symbol
        • Optional descriptor: number | PropertyDescriptor

        Returns void

  • setEnabled(enable: boolean): void
  • Allows an application to disable validation. For example, the package can be enabled during testing and development, and disabled for production use. By default the package is enabled, meaning an internal flag variable is set to true. To disable, call this function with false.

    This can be called as desired to enable or disable dynamically. The effect is for the override functions to fall straight through to calling the original function. This means the override functions are still installed, but will have no effect.

    Parameters

    • enable: boolean

      Change whether the package is enabled

    Returns void