Full Code of typestack/class-validator for AI

develop 2e1a5c27dbd6 cached
204 files
559.7 KB
140.8k tokens
675 symbols
1 requests
Download .txt
Showing preview only (609K chars total). Download the full file or copy to clipboard to get everything.
Repository: typestack/class-validator
Branch: develop
Commit: 2e1a5c27dbd6
Files: 204
Total size: 559.7 KB

Directory structure:
gitextract_sok6jg66/

├── .eslintrc.yml
├── .gitbook.yaml
├── .github/
│   ├── dependabot.yml
│   ├── semantic.yml
│   └── workflows/
│       ├── auto-approve-dependabot-workflow.yml
│       ├── continuous-deployment-workflow.yml
│       ├── continuous-integration-workflow.yml
│       └── lock-closed-issues-workflow.yml
├── .gitignore
├── .prettierrc.yml
├── CHANGELOG.md
├── LICENSE
├── README.md
├── codecov.yml
├── docs/
│   ├── README.md
│   ├── basics/
│   │   └── validating-objects.md
│   └── introduction/
│       └── installation.md
├── jest.config.js
├── package.json
├── rollup.config.js
├── sample/
│   ├── sample1-simple-validation/
│   │   ├── Post.ts
│   │   └── app.ts
│   ├── sample2-using-groups/
│   │   ├── Post.ts
│   │   └── app.ts
│   ├── sample3-nested-objects/
│   │   ├── Post.ts
│   │   ├── Tag.ts
│   │   └── app.ts
│   ├── sample4-custom-validator/
│   │   ├── CustomTextLength.ts
│   │   ├── Post.ts
│   │   └── app.ts
│   ├── sample5-schemas/
│   │   ├── Post.ts
│   │   ├── app.ts
│   │   └── post.json
│   ├── sample6-custom-decorator/
│   │   ├── IsLongerThan.ts
│   │   ├── IsUserAlreadyExist.ts
│   │   ├── User.ts
│   │   └── app.ts
│   ├── sample7-inheritance-support/
│   │   ├── BaseContent.ts
│   │   ├── Post.ts
│   │   └── app.ts
│   ├── sample8-es6-maps/
│   │   ├── Post.ts
│   │   ├── Tag.ts
│   │   └── app.ts
│   └── sample9-es6-sets/
│       ├── Post.ts
│       ├── Tag.ts
│       └── app.ts
├── src/
│   ├── container.ts
│   ├── decorator/
│   │   ├── ValidationOptions.ts
│   │   ├── array/
│   │   │   ├── ArrayContains.ts
│   │   │   ├── ArrayMaxSize.ts
│   │   │   ├── ArrayMinSize.ts
│   │   │   ├── ArrayNotContains.ts
│   │   │   ├── ArrayNotEmpty.ts
│   │   │   └── ArrayUnique.ts
│   │   ├── common/
│   │   │   ├── Allow.ts
│   │   │   ├── Equals.ts
│   │   │   ├── IsDefined.ts
│   │   │   ├── IsEmpty.ts
│   │   │   ├── IsIn.spec.ts
│   │   │   ├── IsIn.ts
│   │   │   ├── IsLatLong.ts
│   │   │   ├── IsLatitude.ts
│   │   │   ├── IsLongitude.ts
│   │   │   ├── IsNotEmpty.ts
│   │   │   ├── IsNotIn.ts
│   │   │   ├── IsOptional.ts
│   │   │   ├── NotEquals.ts
│   │   │   ├── Validate.ts
│   │   │   ├── ValidateBy.ts
│   │   │   ├── ValidateIf.ts
│   │   │   ├── ValidateNested.ts
│   │   │   └── ValidatePromise.ts
│   │   ├── date/
│   │   │   ├── MaxDate.ts
│   │   │   └── MinDate.ts
│   │   ├── decorators.ts
│   │   ├── number/
│   │   │   ├── IsDivisibleBy.ts
│   │   │   ├── IsNegative.ts
│   │   │   ├── IsPositive.ts
│   │   │   ├── Max.ts
│   │   │   └── Min.ts
│   │   ├── object/
│   │   │   ├── IsInstance.ts
│   │   │   └── IsNotEmptyObject.ts
│   │   ├── string/
│   │   │   ├── Contains.ts
│   │   │   ├── IsAlpha.ts
│   │   │   ├── IsAlphanumeric.ts
│   │   │   ├── IsAscii.ts
│   │   │   ├── IsBIC.ts
│   │   │   ├── IsBase32.ts
│   │   │   ├── IsBase58.ts
│   │   │   ├── IsBase64.ts
│   │   │   ├── IsBooleanString.ts
│   │   │   ├── IsBtcAddress.ts
│   │   │   ├── IsByteLength.ts
│   │   │   ├── IsCreditCard.ts
│   │   │   ├── IsCurrency.ts
│   │   │   ├── IsDataURI.ts
│   │   │   ├── IsDateString.ts
│   │   │   ├── IsDecimal.ts
│   │   │   ├── IsEAN.ts
│   │   │   ├── IsEmail.ts
│   │   │   ├── IsEthereumAddress.ts
│   │   │   ├── IsFQDN.ts
│   │   │   ├── IsFirebasePushId.ts
│   │   │   ├── IsFullWidth.ts
│   │   │   ├── IsHSL.ts
│   │   │   ├── IsHalfWidth.ts
│   │   │   ├── IsHash.ts
│   │   │   ├── IsHexColor.ts
│   │   │   ├── IsHexadecimal.ts
│   │   │   ├── IsIBAN.ts
│   │   │   ├── IsIP.ts
│   │   │   ├── IsISBN.ts
│   │   │   ├── IsISIN.ts
│   │   │   ├── IsISO31661Alpha2.ts
│   │   │   ├── IsISO31661Alpha3.ts
│   │   │   ├── IsISO31661Numeric.ts
│   │   │   ├── IsISO8601.ts
│   │   │   ├── IsISRC.ts
│   │   │   ├── IsISSN.ts
│   │   │   ├── IsIdentityCard.ts
│   │   │   ├── IsJSON.ts
│   │   │   ├── IsJWT.ts
│   │   │   ├── IsLocale.ts
│   │   │   ├── IsLowercase.ts
│   │   │   ├── IsMacAddress.ts
│   │   │   ├── IsMagnetURI.ts
│   │   │   ├── IsMilitaryTime.ts
│   │   │   ├── IsMimeType.ts
│   │   │   ├── IsMobilePhone.ts
│   │   │   ├── IsMongoId.ts
│   │   │   ├── IsMultibyte.ts
│   │   │   ├── IsNumberString.ts
│   │   │   ├── IsOctal.ts
│   │   │   ├── IsPassportNumber.ts
│   │   │   ├── IsPhoneNumber.spec.ts
│   │   │   ├── IsPhoneNumber.ts
│   │   │   ├── IsPort.ts
│   │   │   ├── IsPostalCode.ts
│   │   │   ├── IsRFC3339.ts
│   │   │   ├── IsRgbColor.ts
│   │   │   ├── IsSemVer.ts
│   │   │   ├── IsStrongPassword.ts
│   │   │   ├── IsSurrogatePair.ts
│   │   │   ├── IsTimeZone.ts
│   │   │   ├── IsUUID.ts
│   │   │   ├── IsUppercase.ts
│   │   │   ├── IsUrl.ts
│   │   │   ├── IsVariableWidth.ts
│   │   │   ├── Length.ts
│   │   │   ├── Matches.ts
│   │   │   ├── MaxLength.ts
│   │   │   ├── MinLength.ts
│   │   │   ├── NotContains.ts
│   │   │   ├── is-iso4217-currency-code.ts
│   │   │   ├── is-tax-id.ts
│   │   │   └── isISO6391.ts
│   │   └── typechecker/
│   │       ├── IsArray.ts
│   │       ├── IsBoolean.ts
│   │       ├── IsDate.ts
│   │       ├── IsEnum.ts
│   │       ├── IsInt.ts
│   │       ├── IsNumber.ts
│   │       ├── IsObject.ts
│   │       └── IsString.ts
│   ├── index.ts
│   ├── metadata/
│   │   ├── ConstraintMetadata.ts
│   │   ├── MetadataStorage.ts
│   │   ├── ValidationMetadata.ts
│   │   └── ValidationMetadataArgs.ts
│   ├── register-decorator.ts
│   ├── utils/
│   │   ├── convert-to-array.util.ts
│   │   ├── get-global.util.ts
│   │   ├── index.ts
│   │   └── is-promise.util.ts
│   ├── validation/
│   │   ├── ValidationArguments.ts
│   │   ├── ValidationError.ts
│   │   ├── ValidationExecutor.ts
│   │   ├── ValidationTypes.ts
│   │   ├── ValidationUtils.ts
│   │   ├── Validator.ts
│   │   ├── ValidatorConstraintInterface.ts
│   │   └── ValidatorOptions.ts
│   └── validation-schema/
│       ├── ValidationSchema.ts
│       └── ValidationSchemaToMetadataTransformer.ts
├── test/
│   ├── functional/
│   │   ├── conditional-validation.spec.ts
│   │   ├── custom-decorators.spec.ts
│   │   ├── inherited-validation.spec.ts
│   │   ├── nested-validation.spec.ts
│   │   ├── promise-validation.spec.ts
│   │   ├── reject-validation.spec.ts
│   │   ├── sync-validation.spec.ts
│   │   ├── validation-error.spec.ts
│   │   ├── validation-functions-and-decorators.spec.ts
│   │   ├── validation-options.spec.ts
│   │   ├── validator-options.spec.ts
│   │   └── whitelist-validation.spec.ts
│   └── utils.spec.ts
├── tsconfig.json
├── tsconfig.prod.cjs.json
├── tsconfig.prod.esm2015.json
├── tsconfig.prod.esm5.json
├── tsconfig.prod.json
├── tsconfig.prod.types.json
└── tsconfig.spec.json

================================================
FILE CONTENTS
================================================

================================================
FILE: .eslintrc.yml
================================================
parser: '@typescript-eslint/parser'
plugins:
  - '@typescript-eslint'
parserOptions:
  ecmaVersion: 2018
  sourceType: module
  project: 
    - ./tsconfig.json
    - ./tsconfig.spec.json
extends:
  - 'plugin:@typescript-eslint/recommended'
  - 'plugin:@typescript-eslint/recommended-requiring-type-checking'
  - 'plugin:jest/recommended'
  - 'prettier'
rules:
  '@typescript-eslint/explicit-member-accessibility': off
  '@typescript-eslint/no-angle-bracket-type-assertion': off
  '@typescript-eslint/no-parameter-properties': off
  '@typescript-eslint/explicit-function-return-type': off
  '@typescript-eslint/member-delimiter-style': off
  '@typescript-eslint/no-inferrable-types': off
  '@typescript-eslint/no-explicit-any': off
  '@typescript-eslint/member-ordering': 'error'
  '@typescript-eslint/no-unused-vars':
    - 'error'
    - args: 'none'
  # TODO: Remove these and fixed issues once we merged all the current PRs. 
  '@typescript-eslint/ban-types': off 
  '@typescript-eslint/no-unsafe-return': off
  '@typescript-eslint/no-unsafe-assignment': off
  '@typescript-eslint/no-unsafe-call': off
  '@typescript-eslint/no-unsafe-member-access': off
  '@typescript-eslint/no-unsafe-argument': off
  '@typescript-eslint/explicit-module-boundary-types': off
  '@typescript-eslint/restrict-template-expressions': off


================================================
FILE: .gitbook.yaml
================================================
root: docs
structure:
  readme: README.md
  summary: docs/README.md

================================================
FILE: .github/dependabot.yml
================================================
version: 2
updates:
- package-ecosystem: npm
  directory: "/"
  schedule:
    interval: daily
    time: "10:00"
    timezone: Europe/Budapest
  open-pull-requests-limit: 0
  versioning-strategy: increase
  commit-message:
    prefix: build
    include: scope
  ignore:
    - dependency-name: "husky"


================================================
FILE: .github/semantic.yml
================================================
titleAndCommits: true
allowMergeCommits: false
scopes:
  - deps
  - deps-dev
types:
  - feat
  - fix
  - docs
  - style
  - refactor
  - perf
  - test
  - build
  - ci
  - chore
  - revert
  - merge


================================================
FILE: .github/workflows/auto-approve-dependabot-workflow.yml
================================================
name: Dependabot auto-merge
on:
  pull_request_target
jobs:
  dependabot:
    runs-on: ubuntu-latest
    if: github.actor == 'dependabot[bot]'
    steps:
    - name: 'Auto approve PR by Dependabot'
      uses: hmarr/auto-approve-action@v2.0.0
      with:
        github-token: "${{ secrets.TYPESTACK_BOT_TOKEN }}"
    - name: 'Comment merge command'
      uses: actions/github-script@v3
      with:
        github-token: ${{secrets.TYPESTACK_BOT_TOKEN }}
        script: |
          await github.issues.createComment({
            owner: context.repo.owner,
            repo: context.repo.repo,
            issue_number: context.issue.number,
            body: '@dependabot squash and merge'
          })


================================================
FILE: .github/workflows/continuous-deployment-workflow.yml
================================================
name: CD
on:
  release:
    types: [created]
jobs:
  publish:
    name: Publish to NPM
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 'lts/*'
          registry-url: https://registry.npmjs.org
      - run: npm ci --ignore-scripts
      - run: npm run prettier:check
      - run: npm run lint:check
      - run: npm run test:ci
      - run: npm run build:es2015
      - run: npm run build:esm5
      - run: npm run build:cjs
      - run: npm run build:umd
      - run: npm run build:types
      - run: cp LICENSE build/LICENSE
      - run: cp README.md build/README.md
      - run: jq 'del(.devDependencies) | del(.scripts)' package.json > build/package.json
      - run: npm publish ./build
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}


================================================
FILE: .github/workflows/continuous-integration-workflow.yml
================================================
name: CI
on: [push, pull_request]
jobs:
  checks:
    name: Linters
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 'lts/*'
      - run: npm ci --ignore-scripts
      - run: npm run prettier:check
      - run: npm run lint:check
  tests:
    name: Tests
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: ['lts/*', 'current']
      fail-fast: false
    steps:
      - uses: actions/checkout@v3
      - name: Setting up Node.js (v${{ matrix.node-version }}.x)
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
      - run: npm ci --ignore-scripts
      - run: npm run test:ci
      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@v5
        if: ${{ matrix.node-version == 'current' && github.actor != 'dependabot[bot]' }}
        with:
          files: ./coverage/clover.xml
          directory: ./coverage/lcov-report/
          token: ${{ secrets.CODECOV_TOKEN }}
          verbose: true
          fail_ci_if_error: true
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 'lts/*'
      - run: npm ci --ignore-scripts
      - run: npm run build:es2015
      - run: npm run build:esm5
      - run: npm run build:cjs
      - run: npm run build:umd
      - run: npm run build:types


================================================
FILE: .github/workflows/lock-closed-issues-workflow.yml
================================================
name: 'Lock inactive threads'
on:
  schedule:
    - cron: '0 0 * * *'
jobs:
  lock:
    name: Lock closed issues
    runs-on: ubuntu-latest
    steps:
      - uses: dessant/lock-threads@v2
        with:
          github-token: ${{ github.token }}
          issue-lock-inactive-days: 30
          pr-lock-inactive-days: 30
          issue-lock-comment: >
            This issue has been automatically locked since there
            has not been any recent activity after it was closed.
            Please open a new issue for related bugs.
          pr-lock-comment: >
            This pull request has been automatically locked since there
            has not been any recent activity after it was closed.
            Please open a new issue for related bugs.


================================================
FILE: .gitignore
================================================
# Log files
logs
*.log
*.tmp
*.tmp.*
log.txt
npm-debug.log*

# Testing output
lib-cov/**
coverage/**

# Environment files
.env

# Dependency directories
node_modules

# MacOS related files
*.DS_Store
.AppleDouble
.LSOverride
._*
UserInterfaceState.xcuserstate

# Windows related files
Thumbs.db
Desktop.ini
$RECYCLE.BIN/

# IDE - Sublime
*.sublime-project
*.sublime-workspace

# IDE - VSCode
.vscode/**
!.vscode/tasks.json
!.vscode/launch.json

# IDE - IntelliJ
.idea

# Compilation output folders
dist/
build/
tmp/
out-tsc/
temp

# Files for playing around locally
playground.ts
playground.js


================================================
FILE: .prettierrc.yml
================================================
printWidth: 120
tabWidth: 2
useTabs: false
semi: true
singleQuote: true
trailingComma: es5
bracketSpacing: true
arrowParens: avoid


================================================
FILE: CHANGELOG.md
================================================
# Changelog

_This changelog follows the [keep a changelog][keep-a-changelog]_ format to maintain a human readable changelog.

## [0.15.1](https://github.com/typestack/class-validator/compare/v0.14.4...v0.15.1) (2026-02-26)

### BREAKING CHANGES

- Added options argument to IsIBAN validator ([#2618](https://github.com/typestack/class-validator/pull/2618)), which breaks any existing usage of this decorator that pass an argument to the decorator, e.g. `@IsIBAN({forbidUnknownValues: false})`

### Fixed

- Updated lockfile to patch vulnerabilities ([#2669](https://github.com/typestack/class-validator/pull/2669))
- Fixed a small grammatical error in the docs ([#2596](https://github.com/typestack/class-validator/pull/2596))

### Added

- Added `validateIf` option to all validators, providing a lot more flexibility in using conditional validation ([#1579](https://github.com/typestack/class-validator/pull/1579))
- Added IsISO31661Numeric validator for country codes ([#2657](https://github.com/typestack/class-validator/pull/2657))
- Added IsISO6391 validator for language codes ([#2626](https://github.com/typestack/class-validator/pull/2626))
- Added more versions to IsUUID validator options. ([#2647](https://github.com/typestack/class-validator/pull/2647))
-

## [0.14.4](https://github.com/typestack/class-validator/compare/v0.14.3...v0.14.4) (2026-02-25)

- Updated validator.js to 13.15.22 ([#2649](https://github.com/typestack/class-validator/pull/2649))

## [0.14.3](https://github.com/typestack/class-validator/compare/v0.14.1...v0.14.3) (2025-11-24)

- Fixed a vulnerability by bumping validator.js ([#2638](https://github.com/typestack/class-validator/pull/2638) by [@weikangchia](https://github.com/weikangchia))

## [0.14.2](https://github.com/typestack/class-validator/compare/v0.14.1...v0.14.2) (2025-05-02)

#### Fixed

- Fixed an issue where `forbidUnknownValues` did not default to `true` when `validatorOptions` was undefined. ([#2196](https://github.com/typestack/class-validator/pull/2196) by [@cduff](https://github.com/cduff))
- Fixed the `ValidationMetadata.name` property to work correctly with the `@IsOptional` decorator. ([#2044](https://github.com/typestack/class-validator/pull/2044) by [@Clashsoft](https://github.com/Clashsoft))
- Updated the Codecov configuration for continuous integration. ([#2556](https://github.com/typestack/class-validator/pull/2556) by [@haiweilian](https://github.com/haiweilian))
- Fixed an issue where options were not passed correctly to the `@IsBase64` decorator. ([#2549](https://github.com/typestack/class-validator/pull/2549) by [@aseyfpour](https://github.com/aseyfpour))
- Fixed argument handling for the `isBase64` function. ([#2574](https://github.com/typestack/class-validator/pull/2574) by [@braaar](https://github.com/braaar))

### [0.14.1](https://github.com/typestack/class-validator/compare/v0.14.0...v0.14.1) (2024-01-12)

#### Added

- allow specifying options for `@IsBase64` decorator ([#1845](https://github.com/typestack/class-validator/issues/1845)) , closes [#1013](https://github.com/typestack/class-validator/issues/1013)
- use official type for version in `@IsUUID` decorator ([#1846](https://github.com/typestack/class-validator/issues/1846)) , closes [#1497](https://github.com/typestack/class-validator/issues/1497)
- update `@IsPhoneNumber` decorator to use max dataset ([#1857](https://github.com/typestack/class-validator/issues/1857))

#### Fixed

- fail for non-array constraint in `@IsIn` decorator ([#1844](https://github.com/typestack/class-validator/issues/1844)) , closes [#1693](https://github.com/typestack/class-validator/issues/1693)
- allow number and boolean values in validation message "$value" tokens ([#1467](https://github.com/typestack/class-validator/issues/1467)) , closes [#921](https://github.com/typestack/class-validator/issues/921), [#1046](https://github.com/typestack/class-validator/issues/1046)
- read nullable option in `@IsNotEmptyObject` decorator correctly ([#1555](https://github.com/typestack/class-validator/issues/1555)) , closes [#1554](https://github.com/typestack/class-validator/issues/1554)

#### Changed

- update `libphonenumber-js` to `^1.10.53` from `^1.10.14`
- update various dev-dependencies

### [0.14.0](https://github.com/typestack/class-validator/compare/v0.13.2...v0.14.0) (2022-12-09)

### Added

- add `@IsTimeZone` decorator to check if given string is valid IANA time zone
- add `@IsISO4217CurrencyCode` decorator to check if the string is an ISO 4217 currency code
- add `@IsStrongPassword` decorator to check if given password matches specific complexity criteria
- add `@IsBase58` decorator to check if a string is base58 encoded
- add `@IsTaxId` decorator to check if a given string is a valid tax ID in a given locale
- add support for passing function as date generator in `@MinDate` and `@MaxDate` decorators
- add option to print constraint error message instead of constraint type in validation error
- improve decorator metadata lookup performance
- return possible values in error message for `@IsEnum` decorator

### Fixed

- re-added `@types/validator` as dependency
- fix error generation when using `@NestedValidation`
- pass validation options correctly to validator in `@IsDateString` decorator
- support passing `Symbol` as parameter in error message generation
- specify supported locales for `@IsAlphanumeric` decorator
- correctly assign decorator name in metadata instead of loosing it
- fix various spelling errors in documentation
- fix various spelling errors and inconsistencies in JSDoc for decorators

### Changed

- enable `forbidUnknownValues` option by default
- remove documentation about deprecated schema based validation and added warning
- update warning message logged about missing decorator metadata
- update `libphonenumber-js` to `^1.10.14` from `^1.9.43`
- update various dev-dependencies

### BREAKING CHANGES

**`forbidUnknownValues` option is enabled by default**

From this release the `forbidUnknownValues` is enabled by default. This is the desired behavior for majority of
use-cases, but this change may break validation for some. The two scenarios that results in failed validation:

- when attempting to validate a class instance without metadata for it
- when using group validation and the specified validation group results in zero validation applied

The old behavior can be restored via specifying `forbidUnknownValues: false` option when calling the validate functions.

For more details see [PR #1798](https://github.com/typestack/class-validator/pull/1798) and [#1422 (comment)](https://github.com/typestack/class-validator/issues/1422#issuecomment-1317953863).

**`@NestedValidation` decorator correctly assigns validation errors**

Until now the errors from a nested validation in some cases were incorrectly assigned
to the parent instead of the child being validated. Now the validation errors are correctly assigned.

For more details see [#679](https://github.com/typestack/class-validator/issues/679).

### [0.13.2](https://github.com/typestack/class-validator/compare/v0.13.1...v0.13.2) (2021-11-20)

> **NOTE:** This version fixes a security vulnerability allowing denial of service attacks with a specially crafted request payload.
> Please update as soon as possible.

#### Fixed

- switched to use `Array.isArray` in array checks from `instanceof` operator

#### Changed

- `libphonenumber-js` package updated to `1.9.43` from `1.9.7`
- `validator` package updated to `13.5.2` from `13.5.2`
- various dev-dependencies updated

### [0.13.1](https://github.com/typestack/class-validator/compare/v0.13.0...v0.13.1) (2021-01-14)

#### Added

- optional mather function has been added to the `ArrayUnique` decorator

#### Fixed

- a typo was fixed in the error message generated by the `IsUUID` decorator
- calling `ValidationError.toString()` doesn't result in an error when `forbidNonWhitelisted` parameter was used
- fixed typo in error message generated by `IsIn` decorator
- the `@types/validator` package is correctly installed
- `inlineSources` option is enabled in tsconfig preventing various sourcemap errors when consuming the package

#### Changed

- various dev dependencies has been updated

### [0.13.0](https://github.com/typestack/class-validator/compare/v0.12.2...v0.13.0) (2021-01-11)

#### Added

- **project is restructured to allow three-shaking**
- added option to fail on first validation error (#620)
- two new validator option is added:
  - `always` - allows setting global default for `always` option for decorators
  - `strictGroups` - ignore decorators with at least one group, when `ValidatorOptions.groups` is empty

### Fixed

- the 'any' locale is allowed in the `isPostalCode` decorator (#634)
- the `IsDateString()` decorator now aliases the `IsISO8601()` decorator (#672)

#### Changed

- project tooling has been updated significantly
- google-libphonenumber has been replaced with libphonenumber-js (this should have no effect on validation)
- build process generates include both ES/CommonJS and UMD variations
- various dev dependencies has been updated

### [0.12.2](https://github.com/typestack/class-validator/compare/v0.12.1...v0.12.2) (2020-04-23)

#### Fixed

- move `tslib` from `peerDependencies` to `dependencies` ([827eff1](https://github.com/typestack/class-validator/commit/827eff1)), closes [#588](https://github.com/typestack/class-validator/issues/588)

### [0.12.1](https://github.com/typestack/class-validator/compare/v0.12.0...v0.12.1) (2020-04-18)

#### Fixed

- apply only nested validator for ValidateNested multi-dimensional array ([c463be5](https://github.com/typestack/class-validator/commit/c463be5))

### [0.12.0](https://github.com/typestack/class-validator/compare/v0.11.1...v0.12.0) (2020-04-18)

#### Fixed

- accept negative timezone in isDateString ([#564](https://github.com/typestack/class-validator/issues/564)) ([2012d72](https://github.com/typestack/class-validator/commit/2012d72)), closes [#565](https://github.com/typestack/class-validator/issues/565)
- apply all decorators type PropertyDecorator ([#556](https://github.com/typestack/class-validator/issues/556)) ([5fb36e3](https://github.com/typestack/class-validator/commit/5fb36e3)), closes [#555](https://github.com/typestack/class-validator/issues/555)
- avoiding metadataStorage from DI ([#335](https://github.com/typestack/class-validator/issues/335)) ([b57fef4](https://github.com/typestack/class-validator/commit/b57fef4)), closes [#328](https://github.com/typestack/class-validator/issues/328) [#261](https://github.com/typestack/class-validator/issues/261) [#132](https://github.com/typestack/class-validator/issues/132)
- correct registerDecorator options argument ([7909ec6](https://github.com/typestack/class-validator/commit/7909ec6)), closes [#302](https://github.com/typestack/class-validator/issues/302)
- IsNumberString accept isNumbericOptions as argument ([62b993f](https://github.com/typestack/class-validator/commit/62b993f)), closes [#518](https://github.com/typestack/class-validator/issues/518) [#463](https://github.com/typestack/class-validator/issues/463)
- optional `constraints` property in ValidationError ([#465](https://github.com/typestack/class-validator/issues/465)) ([84680ad](https://github.com/typestack/class-validator/commit/84680ad)), closes [#309](https://github.com/typestack/class-validator/issues/309)
- pass context to ValidationError for async validations ([#533](https://github.com/typestack/class-validator/issues/533)) ([4eb1216](https://github.com/typestack/class-validator/commit/4eb1216))
- switch isLatitude & isLongitude validators ([#513](https://github.com/typestack/class-validator/issues/513)) ([5497179](https://github.com/typestack/class-validator/commit/5497179)), closes [#502](https://github.com/typestack/class-validator/issues/502)
- switch isLatitude & isLongitude validators ([#537](https://github.com/typestack/class-validator/issues/537)) ([c27500b](https://github.com/typestack/class-validator/commit/c27500b))
- ValidateNested support multi-dimensional arrays ([#539](https://github.com/typestack/class-validator/issues/539)) ([62678e1](https://github.com/typestack/class-validator/commit/62678e1))

#### Changed

- update build process to enable tree shaking ([#568](https://github.com/typestack/class-validator/issues/568)) ([11a7b8b](https://github.com/typestack/class-validator/commit/11a7b8b)), closes [#258](https://github.com/typestack/class-validator/issues/258) [#248](https://github.com/typestack/class-validator/issues/248) [#247](https://github.com/typestack/class-validator/issues/247) [#212](https://github.com/typestack/class-validator/issues/212)

#### Added

- sync validatorjs version from v10.11.3 to v13.0.0 ([09120b7](https://github.com/typestack/class-validator/commit/09120b7)), closes [#576](https://github.com/typestack/class-validator/issues/576) [#425](https://github.com/typestack/class-validator/issues/425)

### BREAKING CHANGES

- Validatorjs releases contain some breaking changes e.g. `IsMobileNumber` or `IsHexColor`. Please check validatorjs [CHANGELOG](https://github.com/validatorjs/validator.js/blob/master/CHANGELOG.md)
- Validation functions was removed from `Validator` class to enable tree shaking.

  BEFORE:

  ```ts
  import { Validator } from 'class-validator';

  const validator = new Validator();
  validator.isNotIn(value, possibleValues);
  validator.isBoolean(value);
  ```

  AFTER:

  ```ts
  import { isNotIn, isBoolean } from 'class-validator';

  isNotIn(value, possibleValues);
  isBoolean(value);
  ```

- IsNumberString decorator arguments changed to `@IsNumberString(ValidatorJS.IsNumericOptions, ValidationOptions)`.

### [0.11.1](https://github.com/typestack/class-validator/compare/v0.11.0...v0.11.1) (2020-03-18)

#### Fixed

- IsNumber validator now works when maxDecimalPlaces=0 ([#524](https://github.com/typestack/class-validator/issues/524)) ([b8aa922](https://github.com/typestack/class-validator/commit/b8aa922))

#### Added

- add all option in isuuid validator ([#452](https://github.com/typestack/class-validator/issues/452)) ([98e9382](https://github.com/typestack/class-validator/commit/98e9382))
- add IsFirebasePushId validator ([#548](https://github.com/typestack/class-validator/issues/548)) ([e7e2e53](https://github.com/typestack/class-validator/commit/e7e2e53))
- add options for isISO8601 validator ([#460](https://github.com/typestack/class-validator/issues/460)) ([90a6638](https://github.com/typestack/class-validator/commit/90a6638))

### [0.11.0](https://github.com/typestack/class-validator/compare/v0.10.2...v0.11.0) (2019-11-01)

#### Fixed

- create instance of ValidationError for whitelist errors ([#434](https://github.com/typestack/class-validator/issues/434)) ([a98f5dd](https://github.com/typestack/class-validator/commit/a98f5dd)), closes [#325](https://github.com/typestack/class-validator/issues/325)
- pass context for isDefined and custom validators ([#296](https://github.com/typestack/class-validator/issues/296)) ([0ef898e](https://github.com/typestack/class-validator/commit/0ef898e)), closes [#292](https://github.com/typestack/class-validator/issues/292)

#### Added

- add isHash validator ([#445](https://github.com/typestack/class-validator/issues/445)) ([c454cf9](https://github.com/typestack/class-validator/commit/c454cf9))
- add isISSN validator ([#450](https://github.com/typestack/class-validator/issues/450)) ([4bd586e](https://github.com/typestack/class-validator/commit/4bd586e))
- add isJWT validator ([#444](https://github.com/typestack/class-validator/issues/444)) ([874861b](https://github.com/typestack/class-validator/commit/874861b))
- add isMACAddress validator ([#449](https://github.com/typestack/class-validator/issues/449)) ([45b7df7](https://github.com/typestack/class-validator/commit/45b7df7))
- add support for maxDecimalPlaces on IsNumber ([#381](https://github.com/typestack/class-validator/issues/381)) ([a4dc10e](https://github.com/typestack/class-validator/commit/a4dc10e))

### BREAKING CHANGES

- update @types/validator from 11.1.0 to version 12.0.0 - please check it's [changelog][validator-js-release-notes]

### [0.10.2](https://github.com/typestack/class-validator/compare/v0.10.1...v0.10.2) (2019-10-14)

#### Fixed

- apply custom constraint class validation to each item in the array ([#295](https://github.com/typestack/class-validator/issues/295)) ([5bb704e](https://github.com/typestack/class-validator/commit/5bb704e)), closes [#260](https://github.com/typestack/class-validator/issues/260)

#### Added

- add isLatLong, isLatitude, isLongtitude validators ([#427](https://github.com/typestack/class-validator/issues/427)) ([3fd15c4](https://github.com/typestack/class-validator/commit/3fd15c4)), closes [#415](https://github.com/typestack/class-validator/issues/415)
- add IsObject and IsNotEmptyObject new decorators ([#334](https://github.com/typestack/class-validator/issues/334)) ([0a41aeb](https://github.com/typestack/class-validator/commit/0a41aeb))
- support ES6 Map and Set for regular validators with each option ([#430](https://github.com/typestack/class-validator/issues/430)) ([a055bba](https://github.com/typestack/class-validator/commit/a055bba)), closes [#428](https://github.com/typestack/class-validator/issues/428)

### [0.10.1](https://github.com/typestack/class-validator/compare/v0.10.0...v0.10.1) (2019-09-25)

#### Fixed

- add default message for isMilitaryTime validator ([#411](https://github.com/typestack/class-validator/issues/411)) ([204b7df](https://github.com/typestack/class-validator/commit/204b7df)), closes [#287](https://github.com/typestack/class-validator/issues/287)
- add default message for isPort validator ([#404](https://github.com/typestack/class-validator/issues/404)) ([74e568c](https://github.com/typestack/class-validator/commit/74e568c))
- add locale parameter for isAlpha and isAlphanumeric validat… ([#406](https://github.com/typestack/class-validator/issues/406)) ([2f4bf4e](https://github.com/typestack/class-validator/commit/2f4bf4e))

#### Added

- add `skipUndefinedProperties`, `skipNullProperties` options ([#414](https://github.com/typestack/class-validator/issues/414)) ([76c948a](https://github.com/typestack/class-validator/commit/76c948a)), closes [#308](https://github.com/typestack/class-validator/issues/308)

### [0.10.0](https://github.com/typestack/class-validator/compare/v0.9.1...v0.10.0) (2019-08-10)

#### Fixed

- add correct signature for custom error message handler ([249c41d](https://github.com/typestack/class-validator/commit/249c41d))

#### Added

- add `IsISO31661Alpha3` and `IsISO31661Alpha2` validators ([#273](https://github.com/typestack/class-validator/issues/273)) ([55c57b3](https://github.com/typestack/class-validator/commit/55c57b3))
- **IsDecimal:** implement `IsDecimal` from validatorjs ([#359](https://github.com/typestack/class-validator/issues/359)) ([b4c8e21](https://github.com/typestack/class-validator/commit/b4c8e21))
- add `isPort` decorator ([#282](https://github.com/typestack/class-validator/issues/282)) ([36684ec](https://github.com/typestack/class-validator/commit/36684ec))
- allow validate Map/Set ([#365](https://github.com/typestack/class-validator/issues/365)) ([f6fcdc5](https://github.com/typestack/class-validator/commit/f6fcdc5))
- new `ValidatePromise` decorator - resolve promise before validate ([#369](https://github.com/typestack/class-validator/issues/369)) ([35ec04d](https://github.com/typestack/class-validator/commit/35ec04d))
- replace instanceof Promise and support Promise/A+ ([#310](https://github.com/typestack/class-validator/issues/310)) ([59eac09](https://github.com/typestack/class-validator/commit/59eac09))
- `isNumberString` now accept validator.js `IsNumericOptions` as second parameter ([#262](https://github.com/typestack/class-validator/issues/262))

### BREAKING CHANGES

- update @types/validator from 10.4.0 to version 10.11.2 - please check it's [changelog][validator-js-release-notes] ([cb960dd](https://github.com/typestack/class-validator/commit/cb960dd))
- `isDateString` now check to match only entire ISO Date ([#275](https://github.com/typestack/class-validator/issues/275)) ([5012464](https://github.com/typestack/class-validator/commit/5012464))
- remove `IsCurrencyOptions`, `IsURLOptions`, `IsEmailOptions`, `IsFQDNOptions` interfaces and replace with interfaces from `@types/validator`

### [0.9.1](https://github.com/typestack/class-validator/compare/v0.9.0...v0.9.1)

#### Added

- added option to pass custom context for the decorators

#### Fixed

- validating against a schema will validate against that one instead of every registered one

### [0.9.0](https://github.com/typestack/class-validator/compare/v0.8.5...v0.9.0) [BREAKING CHANGE]

#### Added

- updated [validator.js][validator-js] from 9.2.0 to 10.4.0 (Check it's [changelog][validator-js-release-notes] for what has changed.)
  - until now fractional numbers was not allowed in the `IsNumberString` decorator, now they are allowed
  - until now Gmail addresses could contain multiple dots or random text after a `+` symbol, this is not allowed anymore
- `IsPhoneNumber` decorator has been added which uses the [google-libphonenumber][google-libphonenumber] library to validate international phone numbers accurately

#### Fixed

- update `IsURLOptions` to match underlying validator host list options
- added a console warning when no metadata decorator is found as it's possibly not intended
- the `Min` and `Max` decorator will corectly show an inclusive error message when failing
- fixed a runtime error when `validationArguments.value` is not a string

### [0.8.5](https://github.com/typestack/class-validator/compare/v0.8.4...v0.8.5)

#### Fixed

- remove `ansicolor` package, because it's incompatible with IE

### [0.8.4](https://github.com/typestack/class-validator/compare/v0.8.3...v0.8.4)

#### Added

- `ValidatorOptions` now has a `forbidUnknownValues` key to prevent unknown objects to pass validation
  - it's highly advised to turn this option on
  - now this option defaults to `false` but will be default to `true` after the **1.0** release

### [0.8.3](https://github.com/typestack/class-validator/compare/v0.8.2...v0.8.3)

#### Fixed

- handle when `target` property is undefined when calling `ValidationError.toString()`

### [0.8.2](https://github.com/typestack/class-validator/compare/v0.8.1...v0.8.2)

#### Added

- added `ValidationError.toString()` method for easier debugging
- added `printError` method to pretty-print errors in NodeJS or the browser

#### Fixed

- fixed wrong type info in `ValidatorOptions`
- fixed wrong type info in `ValidationSchema` \(the `options` key now is optional\)
- corrected `IsNumericString` to `IsNumberString` in the README
- fixed type of `host_whitelist` and `host_backlist` in `IsURLOptions`

### [0.8.1](https://github.com/typestack/class-validator/compare/v0.8.0...v0.8.1)

#### Fixed

- fixed wrong type info in `ValidatorOptions`

### 0.8.0 \[BREAKING CHANGE\]

##### Added

- updated [validator.js][validator-js] from 7.0.0 to 9.2.0 (Check it's [changelog][validator-js-release-notes] for what has changed.)

  This caused breaking change, if you used the `IsUrl` decorator to validate `localhost` as a valid url, from now you must use the `require_tld: false` option

  ```typescript
  @IsUrl({ require_tld: false})
  url: string;
  ```

- added `@IsInstance` decorator and `validator.isInstance(value, target)` method.
- changed `@IsNumber` decorator has been changed to `@IsNumber(options: IsNumberOptions)`
- added option to strip unknown properties \(`whitelist: true`\)
- added option to throw error on unknown properties \(`forbidNonWhitelisted: true`\)
- added `@Allow` decorator to prevent stripping properties without other constraint

#### Fixed

- fixed issue with `@IsDateString` now it allow dates without fraction seconds to be set
- fixed issue with `@IsDateString` now it allow dates without with timezones to be set
- `@ValidateNested` correctly generates validation error on non object and non array values

### 0.6.7

#### Fixed

- fixed issue with `@ValidateNested` when nested property is not defined and it throw an error \(\#59\)

### 0.6.5

#### Fixed

- fixed bugs with `@IsUrl`, `@IsEmail` and several other decorators

### 0.6.4

#### Added

- added `@IsMilitaryTime` decorator.

### 0.6.3

#### Added

- added `validateOrReject` method which rejects promise instead of returning array of errors in resolved result

### 0.6.1

#### Added

- added `@IsArray` decorator.

### 0.6.0 \[BREAKING CHANGE\]

#### Added

- breaking change with `@ValidateNested` on arrays: Validator now groups the validation errors by sub-object, rather than them all being grouped together. See \#32 for a demonstration of the updated structure.
- added `@ValidateIf` decorator, see conditional validation in docs.

### 0.5.0 \[BREAKING CHANGE\]

#### Added

- async validations must be marked with `{ async: true }` option now.

  This is optional, but it helps to determine which decorators are async to prevent their execution in `validateSync` method.

- added `validateSync` method that performs non asynchronous validation and ignores validations that marked with `async: true`.
- there is a breaking change in `registerDecorator` method. Now it accepts options object.
- breaking change with `@ValidatorConstraint` decorator. Now it accepts option object instead of single name.

### 0.4.1

#### Fixed

- fixed issue with wrong source maps packaged

### 0.4.0 \[BREAKING CHANGE\]

#### Added

- everything should be imported from "class-validator" main entry point now
- `ValidatorInterface` has been renamed to `ValidatorConstraintInterface`
- contain can be set in the main entry point now
- some decorator's names changed. Be aware of this
- added few more non-string decorators
- validator now returns array of ValidationError instead of ValidationErrorInterface. Removed old ValidationError
- removed all other validation methods except `validator.validate`
- finally validate method is async now, so custom async validations are supported now
- added ability to validate inherited properties
- added support of separate validation schemas
- added support of default validation messages
- added support of special tokens in validation messages
- added support of message functions in validation options
- added support of custom decorators
- if no groups were specified, decorators with groups now are being ignored
- changed signature of the `ValidationError`. Now if it has nested errors it does not return them in a flat array

#### Fixed

- fixed all decorators that should not work only with strings

### 0.3.0

#### Added

- package has changed its name from `validator.ts` to `class-validator`.
- sanitation functionality has been removed from this library. Use [class-sanitizer][class-sanitizer] instead.

[class-sanitizer]: https://github.com/typestack/class-validator/class-sanitizer
[validator-js]: https://github.com/chriso/validator.js
[validator-js-release-notes]: https://github.com/chriso/validator.js/blob/master/CHANGELOG.md
[google-libphonenumber]: https://github.com/ruimarinho/google-libphonenumber
[keep-a-changelog]: https://keepachangelog.com/en/1.0.0/


================================================
FILE: LICENSE
================================================

The MIT License

Copyright (c) 2015-2020 TypeStack

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

================================================
FILE: README.md
================================================
# class-validator

![Build Status](https://github.com/typestack/class-validator/workflows/CI/badge.svg)
[![codecov](https://codecov.io/gh/typestack/class-validator/branch/develop/graph/badge.svg)](https://codecov.io/gh/typestack/class-validator)
[![npm version](https://badge.fury.io/js/class-validator.svg)](https://badge.fury.io/js/class-validator)
[![install size](https://packagephobia.now.sh/badge?p=class-validator)](https://packagephobia.now.sh/result?p=class-validator)

Allows use of decorator and non-decorator based validation.
Internally uses [validator.js][1] to perform validation.
Class-validator works on both browser and node.js platforms.

## Table of Contents

- [class-validator](#class-validator)
  - [Table of Contents](#table-of-contents)
  - [Installation](#installation)
  - [Usage](#usage)
    - [Passing options](#passing-options)
  - [Validation errors](#validation-errors)
  - [Validation messages](#validation-messages)
  - [Validating arrays](#validating-arrays)
  - [Validating sets](#validating-sets)
  - [Validating maps](#validating-maps)
  - [Validating nested objects](#validating-nested-objects)
  - [Validating promises](#validating-promises)
  - [Inheriting Validation decorators](#inheriting-validation-decorators)
  - [Conditional validation](#conditional-validation)
  - [Whitelisting](#whitelisting)
  - [Passing context to decorators](#passing-context-to-decorators)
  - [Skipping missing properties](#skipping-missing-properties)
  - [Validation groups](#validation-groups)
  - [Custom validation classes](#custom-validation-classes)
  - [Custom validation decorators](#custom-validation-decorators)
  - [Using service container](#using-service-container)
  - [Synchronous validation](#synchronous-validation)
  - [Manual validation](#manual-validation)
  - [Validation decorators](#validation-decorators)
  - [Defining validation schema without decorators](#defining-validation-schema-without-decorators)
  - [Validating plain objects](#validating-plain-objects)
  - [Samples](#samples)
  - [Extensions](#extensions)
  - [Release notes](#release-notes)
  - [Contributing](#contributing)

## Installation

```sh
npm install class-validator --save
```

> Note: Please use at least npm@6 when using class-validator. From npm@6 the dependency tree is flattened, which is required by `class-validator` to function properly.

## Usage

Create your class and put some validation decorators on the properties you want to validate:

```typescript
import {
  validate,
  validateOrReject,
  Contains,
  IsInt,
  Length,
  IsEmail,
  IsFQDN,
  IsDate,
  Min,
  Max,
} from 'class-validator';

export class Post {
  @Length(10, 20)
  title: string;

  @Contains('hello')
  text: string;

  @IsInt()
  @Min(0)
  @Max(10)
  rating: number;

  @IsEmail()
  email: string;

  @IsFQDN()
  site: string;

  @IsDate()
  createDate: Date;
}

let post = new Post();
post.title = 'Hello'; // should not pass
post.text = 'this is a great post about hell world'; // should not pass
post.rating = 11; // should not pass
post.email = 'google.com'; // should not pass
post.site = 'googlecom'; // should not pass

validate(post).then(errors => {
  // errors is an array of validation errors
  if (errors.length > 0) {
    console.log('validation failed. errors: ', errors);
  } else {
    console.log('validation succeed');
  }
});

validateOrReject(post).catch(errors => {
  console.log('Promise rejected (validation failed). Errors: ', errors);
});
// or
async function validateOrRejectExample(input) {
  try {
    await validateOrReject(input);
  } catch (errors) {
    console.log('Caught promise rejection (validation failed). Errors: ', errors);
  }
}
```

### Passing options

The `validate` function optionally expects a `ValidatorOptions` object as a second parameter:

```ts
export interface ValidatorOptions {
  skipMissingProperties?: boolean;
  whitelist?: boolean;
  forbidNonWhitelisted?: boolean;
  groups?: string[];
  dismissDefaultMessages?: boolean;
  validationError?: {
    target?: boolean;
    value?: boolean;
  };

  forbidUnknownValues?: boolean;
  stopAtFirstError?: boolean;
}
```

> **IMPORTANT**
> The `forbidUnknownValues` value is set to `true` by default and **it is highly advised to keep the default**.
> Setting it to `false` will result unknown objects passing the validation!

## Validation errors

The `validate` method returns an array of `ValidationError` objects. Each `ValidationError` is:

```typescript
{
    target: Object; // Object that was validated.
    property: string; // Object's property that haven't pass validation.
    value: any; // Value that haven't pass a validation.
    constraints?: { // Constraints that failed validation with error messages.
        [type: string]: string;
    };
    children?: ValidationError[]; // Contains all nested validation errors of the property
}
```

In our case, when we validated a Post object, we have such an array of `ValidationError` objects:

```typescript
[{
    target: /* post object */,
    property: "title",
    value: "Hello",
    constraints: {
        length: "$property must be longer than or equal to 10 characters"
    }
}, {
    target: /* post object */,
    property: "text",
    value: "this is a great post about hell world",
    constraints: {
        contains: "text must contain a hello string"
    }
},
// and other errors
]
```

If you don't want a `target` to be exposed in validation errors, there is a special option when you use validator:

```typescript
validator.validate(post, { validationError: { target: false } });
```

This is especially useful when you send errors back over http, and you most probably don't want to expose
the whole target object.

## Validation messages

You can specify validation message in the decorator options and that message will be returned in the `ValidationError`
returned by the `validate` method (in the case that validation for this field fails).

```typescript
import { MinLength, MaxLength } from 'class-validator';

export class Post {
  @MinLength(10, {
    message: 'Title is too short',
  })
  @MaxLength(50, {
    message: 'Title is too long',
  })
  title: string;
}
```

There are few special tokens you can use in your messages:

- `$value` - the value that is being validated
- `$property` - name of the object's property being validated
- `$target` - name of the object's class being validated
- `$constraint1`, `$constraint2`, ... `$constraintN` - constraints defined by specific validation type

Example of usage:

```typescript
import { MinLength, MaxLength } from 'class-validator';

export class Post {
  @MinLength(10, {
    // here, $constraint1 will be replaced with "10", and $value with actual supplied value
    message: 'Title is too short. Minimal length is $constraint1 characters, but actual is $value',
  })
  @MaxLength(50, {
    // here, $constraint1 will be replaced with "50", and $value with actual supplied value
    message: 'Title is too long. Maximal length is $constraint1 characters, but actual is $value',
  })
  title: string;
}
```

Also you can provide a function, that returns a message. This allows you to create more granular messages:

```typescript
import { MinLength, MaxLength, ValidationArguments } from 'class-validator';

export class Post {
  @MinLength(10, {
    message: (args: ValidationArguments) => {
      if (args.value.length === 1) {
        return 'Too short, minimum length is 1 character';
      } else {
        return 'Too short, minimum length is ' + args.constraints[0] + ' characters';
      }
    },
  })
  title: string;
}
```

Message function accepts `ValidationArguments` which contains the following information:

- `value` - the value that is being validated
- `constraints` - array of constraints defined by specific validation type
- `targetName` - name of the object's class being validated
- `object` - object that is being validated
- `property` - name of the object's property being validated

## Validating arrays

If your field is an array and you want to perform validation of each item in the array you must specify a
special `each: true` decorator option:

```typescript
import { MinLength, MaxLength } from 'class-validator';

export class Post {
  @MaxLength(20, {
    each: true,
  })
  tags: string[];
}
```

This will validate each item in `post.tags` array.

## Validating sets

If your field is a set and you want to perform validation of each item in the set you must specify a
special `each: true` decorator option:

```typescript
import { MinLength, MaxLength } from 'class-validator';

export class Post {
  @MaxLength(20, {
    each: true,
  })
  tags: Set<string>;
}
```

This will validate each item in `post.tags` set.

## Validating maps

If your field is a map and you want to perform validation of each item in the map you must specify a
special `each: true` decorator option:

```typescript
import { MinLength, MaxLength } from 'class-validator';

export class Post {
  @MaxLength(20, {
    each: true,
  })
  tags: Map<string, string>;
}
```

This will validate each item in `post.tags` map.

## Validating nested objects

If your object contains nested objects and you want the validator to perform their validation too, then you need to
use the `@ValidateNested()` decorator:

```typescript
import { ValidateNested } from 'class-validator';

export class Post {
  @ValidateNested()
  user: User;
}
```

Please note that nested object _must_ be an instance of a class, otherwise `@ValidateNested` won't know what class is target of validation. Check also [Validating plain objects](#validating-plain-objects).

It also works with multi-dimensional array, like :

```typescript
import { ValidateNested } from 'class-validator';

export class Plan2D {
  @ValidateNested()
  matrix: Point[][];
}
```

## Validating promises

If your object contains property with `Promise`-returned value that should be validated, then you need to use the `@ValidatePromise()` decorator:

```typescript
import { ValidatePromise, Min } from 'class-validator';

export class Post {
  @Min(0)
  @ValidatePromise()
  userId: Promise<number>;
}
```

It also works great with `@ValidateNested` decorator:

```typescript
import { ValidateNested, ValidatePromise } from 'class-validator';

export class Post {
  @ValidateNested()
  @ValidatePromise()
  user: Promise<User>;
}
```

## Inheriting Validation decorators

When you define a subclass which extends from another one, the subclass will automatically inherit the parent's decorators. If a property is redefined in the descendant, class decorators will be applied on it from both its own class and the base class.

```typescript
import { validate } from 'class-validator';

class BaseContent {
  @IsEmail()
  email: string;

  @IsString()
  password: string;
}

class User extends BaseContent {
  @MinLength(10)
  @MaxLength(20)
  name: string;

  @Contains('hello')
  welcome: string;

  @MinLength(20)
  password: string;
}

let user = new User();

user.email = 'invalid email'; // inherited property
user.password = 'too short'; // password wil be validated not only against IsString, but against MinLength as well
user.name = 'not valid';
user.welcome = 'helo';

validate(user).then(errors => {
  // ...
}); // it will return errors for email, password, name and welcome properties
```

## Conditional validation

The conditional validation decorator (`@ValidateIf`) can be used to ignore the validators on a property when the provided condition function returns false. The condition function takes the object being validated and must return a `boolean`.

```typescript
import { ValidateIf, IsNotEmpty } from 'class-validator';

export class Post {
  otherProperty: string;

  @ValidateIf(o => o.otherProperty === 'value')
  @IsNotEmpty()
  example: string;
}
```

In the example above, the validation rules applied to `example` won't be run unless the object's `otherProperty` is `"value"`.

Note that when the condition is false all validation decorators are ignored, including `isDefined`.

## Whitelisting

Even if your object is an instance of a validation class it can contain additional properties that are not defined.
If you do not want to have such properties on your object, pass special flag to `validate` method:

```typescript
import { validate } from 'class-validator';
// ...
validate(post, { whitelist: true });
```

This will strip all properties that don't have any decorators. If no other decorator is suitable for your property,
you can use @Allow decorator:

```typescript
import {validate, Allow, Min} from "class-validator";

export class Post {

    @Allow()
    title: string;

    @Min(0)
    views: number;

    nonWhitelistedProperty: number;
}

let post = new Post();
post.title = 'Hello world!';
post.views = 420;

post.nonWhitelistedProperty = 69;
(post as any).anotherNonWhitelistedProperty = "something";

validate(post).then(errors => {
  // post.nonWhitelistedProperty is not defined
  // (post as any).anotherNonWhitelistedProperty is not defined
  ...
});
```

If you would rather to have an error thrown when any non-whitelisted properties are present, pass another flag to
`validate` method:

```typescript
import { validate } from 'class-validator';
// ...
validate(post, { whitelist: true, forbidNonWhitelisted: true });
```

## Passing context to decorators

It's possible to pass a custom object to decorators which will be accessible on the `ValidationError` instance of the property if validation failed.

```ts
import { validate } from 'class-validator';

class MyClass {
  @MinLength(32, {
    message: 'EIC code must be at least 32 characters',
    context: {
      errorCode: 1003,
      developerNote: 'The validated string must contain 32 or more characters.',
    },
  })
  eicCode: string;
}

const model = new MyClass();

validate(model).then(errors => {
  //errors[0].contexts['minLength'].errorCode === 1003
});
```

## Skipping missing properties

Sometimes you may want to skip validation of the properties that do not exist in the validating object. This is
usually desirable when you want to update some parts of the object, and want to validate only updated parts,
but skip everything else, e.g. skip missing properties.
In such situations you will need to pass a special flag to `validate` method:

```typescript
import { validate } from 'class-validator';
// ...
validate(post, { skipMissingProperties: true });
```

When skipping missing properties, sometimes you want not to skip all missing properties, some of them maybe required
for you, even if skipMissingProperties is set to true. For such cases you should use `@IsDefined()` decorator.
`@IsDefined()` is the only decorator that ignores `skipMissingProperties` option.

## Validation groups

In different situations you may want to use different validation schemas of the same object.
In such cases you can use validation groups.

> **IMPORTANT**
> Calling a validation with a group combination that would not result in a validation (eg: non existent group name)
> will result in a unknown value error. When validating with groups the provided group combination should match at least one decorator.

```typescript
import { validate, Min, Length } from 'class-validator';

export class User {
  @Min(12, {
    groups: ['registration'],
  })
  age: number;

  @Length(2, 20, {
    groups: ['registration', 'admin'],
  })
  name: string;
}

let user = new User();
user.age = 10;
user.name = 'Alex';

validate(user, {
  groups: ['registration'],
}); // this will not pass validation

validate(user, {
  groups: ['admin'],
}); // this will pass validation

validate(user, {
  groups: ['registration', 'admin'],
}); // this will not pass validation

validate(user, {
  groups: undefined, // the default
}); // this will not pass validation since all properties get validated regardless of their groups

validate(user, {
  groups: [],
}); // this will not pass validation, (equivalent to 'groups: undefined', see above)
```

There is also a special flag `always: true` in validation options that you can use. This flag says that this validation
must be applied always no matter which group is used.

## Validation option validateIf

If you want an individual validaton decorator to apply conditionally, you can you can use the option `validateIf` available to all validators.
This allows more granular control than the `@ValidateIf` decorator which toggles all validators on the property, but keep in mind that
with great power comes great responsibility: Take care not to create unnecessarily complex validation logic.

```typescript
class MyClass {
  @Min(5, {
    message: 'min',
    validateIf: (obj: MyClass, value) => {
      return !obj.someOtherProperty || obj.someOtherProperty === 'min';
    },
  })
  @Max(3, {
    message: 'max',
    validateIf: (o: MyClass) => !o.someOtherProperty || o.someOtherProperty === 'max',
  })
  someProperty: number;

  someOtherProperty: string;
}

const model = new MyClass();
model.someProperty = 4;
model.someOtherProperty = 'min';
validator.validate(model); // this only validate min

const model = new MyClass();
model.someProperty = 4;
model.someOtherProperty = 'max';
validator.validate(model); // this only validate max

const model = new MyClass();
model.someProperty = 4;
model.someOtherProperty = '';
validator.validate(model); // this validate both

const model = new MyClass();
model.someProperty = 4;
model.someOtherProperty = 'other';
validator.validate(model); // this validate none
```

## Custom validation classes

If you have custom validation logic you can create a _Constraint class_:

1. First create a file, lets say `CustomTextLength.ts`, and define a new class:

   ```typescript
   import { ValidatorConstraint, ValidatorConstraintInterface, ValidationArguments } from 'class-validator';

   @ValidatorConstraint({ name: 'customText', async: false })
   export class CustomTextLength implements ValidatorConstraintInterface {
     validate(text: string, args: ValidationArguments) {
       return text.length > 1 && text.length < 10; // for async validations you must return a Promise<boolean> here
     }

     defaultMessage(args: ValidationArguments) {
       // here you can provide default error message if validation failed
       return 'Text ($value) is too short or too long!';
     }
   }
   ```

   We marked our class with `@ValidatorConstraint` decorator.
   You can also supply a validation constraint name - this name will be used as "error type" in ValidationError.
   If you will not supply a constraint name - it will be auto-generated.

   Our class must implement `ValidatorConstraintInterface` interface and its `validate` method,
   which defines validation logic. If validation succeeds, method returns true, otherwise false.
   Custom validator can be asynchronous, if you want to perform validation after some asynchronous
   operations, simply return a promise with boolean inside in `validate` method.

   Also we defined optional method `defaultMessage` which defines a default error message,
   in the case that the decorator's implementation doesn't set an error message.

2. Then you can use your new validation constraint in your class:

   ```typescript
   import { Validate } from 'class-validator';
   import { CustomTextLength } from './CustomTextLength';

   export class Post {
     @Validate(CustomTextLength, {
       message: 'Title is too short or long!',
     })
     title: string;
   }
   ```

   Here we set our newly created `CustomTextLength` validation constraint for `Post.title`.

3. And use validator as usual:

   ```typescript
   import { validate } from 'class-validator';

   validate(post).then(errors => {
     // ...
   });
   ```

You can also pass constraints to your validator, like this:

```typescript
import { Validate } from 'class-validator';
import { CustomTextLength } from './CustomTextLength';

export class Post {
  @Validate(CustomTextLength, [3, 20], {
    message: 'Wrong post title',
  })
  title: string;
}
```

And use them from `validationArguments` object:

```typescript
import { ValidationArguments, ValidatorConstraint, ValidatorConstraintInterface } from 'class-validator';

@ValidatorConstraint()
export class CustomTextLength implements ValidatorConstraintInterface {
  validate(text: string, validationArguments: ValidationArguments) {
    return text.length > validationArguments.constraints[0] && text.length < validationArguments.constraints[1];
  }
}
```

## Custom validation decorators

You can also create a custom decorator. It's the most elegant way of using custom validations.
Lets create a decorator called `@IsLongerThan`:

1. Create a decorator itself:

   ```typescript
   import { registerDecorator, ValidationOptions, ValidationArguments } from 'class-validator';

   export function IsLongerThan(property: string, validationOptions?: ValidationOptions) {
     return function (object: Object, propertyName: string) {
       registerDecorator({
         name: 'isLongerThan',
         target: object.constructor,
         propertyName: propertyName,
         constraints: [property],
         options: validationOptions,
         validator: {
           validate(value: any, args: ValidationArguments) {
             const [relatedPropertyName] = args.constraints;
             const relatedValue = (args.object as any)[relatedPropertyName];
             return typeof value === 'string' && typeof relatedValue === 'string' && value.length > relatedValue.length; // you can return a Promise<boolean> here as well, if you want to make async validation
           },
         },
       });
     };
   }
   ```

2. Put it to use:

   ```typescript
   import { IsLongerThan } from './IsLongerThan';

   export class Post {
     title: string;

     @IsLongerThan('title', {
       /* you can also use additional validation options, like "groups" in your custom validation decorators. "each" is not supported */
       message: 'Text must be longer than the title',
     })
     text: string;
   }
   ```

In your custom decorators you can also use `ValidationConstraint`.
Lets create another custom validation decorator called `IsUserAlreadyExist`:

1. Create a ValidationConstraint and decorator:

   ```typescript
   import {
     registerDecorator,
     ValidationOptions,
     ValidatorConstraint,
     ValidatorConstraintInterface,
     ValidationArguments,
   } from 'class-validator';

   @ValidatorConstraint({ async: true })
   export class IsUserAlreadyExistConstraint implements ValidatorConstraintInterface {
     validate(userName: any, args: ValidationArguments) {
       return UserRepository.findOneByName(userName).then(user => {
         if (user) return false;
         return true;
       });
     }
   }

   export function IsUserAlreadyExist(validationOptions?: ValidationOptions) {
     return function (object: Object, propertyName: string) {
       registerDecorator({
         target: object.constructor,
         propertyName: propertyName,
         options: validationOptions,
         constraints: [],
         validator: IsUserAlreadyExistConstraint,
       });
     };
   }
   ```

   note that we marked our constraint that it will by async by adding `{ async: true }` in validation options.

2. And put it to use:

   ```typescript
   import { IsUserAlreadyExist } from './IsUserAlreadyExist';

   export class User {
     @IsUserAlreadyExist({
       message: 'User $value already exists. Choose another name.',
     })
     name: string;
   }
   ```

## Using service container

Validator supports service container in the case if want to inject dependencies into your custom validator constraint
classes. Here is example how to integrate it with [typedi][2]:

```typescript
import { Container } from 'typedi';
import { useContainer, Validator } from 'class-validator';

// do this somewhere in the global application level:
useContainer(Container);
let validator = Container.get(Validator);

// now everywhere you can inject Validator class which will go from the container
// also you can inject classes using constructor injection into your custom ValidatorConstraint-s
```

## Synchronous validation

If you want to perform a simple non async validation you can use `validateSync` method instead of regular `validate`
method. It has the same arguments as `validate` method. But note, this method **ignores** all async validations
you have.

## Manual validation

There are several method exist in the Validator that allows to perform non-decorator based validation:

```typescript
import { isEmpty, isBoolean } from 'class-validator';

isEmpty(value);
isBoolean(value);
```

## Validation decorators

| Decorator                                              | Description                                                                                                                                                                                           |
| ------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Common validation decorators**                       |                                                                                                                                                                                                       |
| `@IsDefined(value: any)`                               | Checks if value is defined (!== undefined, !== null). This is the only decorator that ignores skipMissingProperties option.                                                                           |
| `@IsOptional()`                                        | Checks if given value is empty (=== null, === undefined) and if so, ignores all the validators on the property.                                                                                       |
| `@Equals(comparison: any)`                             | Checks if value equals ("===") comparison.                                                                                                                                                            |
| `@NotEquals(comparison: any)`                          | Checks if value not equal ("!==") comparison.                                                                                                                                                         |
| `@IsEmpty()`                                           | Checks if given value is empty (=== '', === null, === undefined).                                                                                                                                     |
| `@IsNotEmpty()`                                        | Checks if given value is not empty (!== '', !== null, !== undefined).                                                                                                                                 |
| `@IsIn(values: any[])`                                 | Checks if value is in an array of allowed values.                                                                                                                                                     |
| `@IsNotIn(values: any[])`                              | Checks if value is not in an array of disallowed values.                                                                                                                                              |
| **Type validation decorators**                         |                                                                                                                                                                                                       |
| `@IsBoolean()`                                         | Checks if a value is a boolean.                                                                                                                                                                       |
| `@IsDate()`                                            | Checks if the value is a date.                                                                                                                                                                        |
| `@IsString()`                                          | Checks if the value is a string.                                                                                                                                                                      |
| `@IsNumber(options: IsNumberOptions)`                  | Checks if the value is a number.                                                                                                                                                                      |
| `@IsInt()`                                             | Checks if the value is an integer number.                                                                                                                                                             |
| `@IsArray()`                                           | Checks if the value is an array                                                                                                                                                                       |
| `@IsEnum(entity: object)`                              | Checks if the value is a valid enum                                                                                                                                                                   |
| **Number validation decorators**                       |
| `@IsDivisibleBy(num: number)`                          | Checks if the value is a number that's divisible by another.                                                                                                                                          |
| `@IsPositive()`                                        | Checks if the value is a positive number greater than zero.                                                                                                                                           |
| `@IsNegative()`                                        | Checks if the value is a negative number smaller than zero.                                                                                                                                           |
| `@Min(min: number)`                                    | Checks if the given number is greater than or equal to given number.                                                                                                                                  |
| `@Max(max: number)`                                    | Checks if the given number is less than or equal to given number.                                                                                                                                     |
| **Date validation decorators**                         |
| `@MinDate(date: Date \| (() => Date))`                 | Checks if the value is a date that's after the specified date.                                                                                                                                        |
| `@MaxDate(date: Date \| (() => Date))`                 | Checks if the value is a date that's before the specified date.                                                                                                                                       |
| **String-type validation decorators**                  |                                                                                                                                                                                                       |
| `@IsBooleanString()`                                   | Checks if a string is a boolean (e.g. is "true" or "false" or "1", "0").                                                                                                                              |
| `@IsDateString()`                                      | Alias for `@IsISO8601()`.                                                                                                                                                                             |
| `@IsNumberString(options?: IsNumericOptions)`          | Checks if a string is a number.                                                                                                                                                                       |
| **String validation decorators**                       |                                                                                                                                                                                                       |
| `@Contains(seed: string)`                              | Checks if the string contains the seed.                                                                                                                                                               |
| `@NotContains(seed: string)`                           | Checks if the string not contains the seed.                                                                                                                                                           |
| `@IsAlpha()`                                           | Checks if the string contains only letters (a-zA-Z).                                                                                                                                                  |
| `@IsAlphanumeric()`                                    | Checks if the string contains only letters and numbers.                                                                                                                                               |
| `@IsDecimal(options?: IsDecimalOptions)`               | Checks if the string is a valid decimal value. Default IsDecimalOptions are `force_decimal=False`, `decimal_digits: '1,'`, `locale: 'en-US'`                                                          |
| `@IsAscii()`                                           | Checks if the string contains ASCII chars only.                                                                                                                                                       |
| `@IsBase32()`                                          | Checks if a string is base32 encoded.                                                                                                                                                                 |
| `@IsBase58()`                                          | Checks if a string is base58 encoded.                                                                                                                                                                 |
| `@IsBase64(options?: IsBase64Options)`                 | Checks if a string is base64 encoded.                                                                                                                                                                 |
| `@IsIBAN()`                                            | Checks if a string is a IBAN (International Bank Account Number).                                                                                                                                     |
| `@IsBIC()`                                             | Checks if a string is a BIC (Bank Identification Code) or SWIFT code.                                                                                                                                 |
| `@IsByteLength(min: number, max?: number)`             | Checks if the string's length (in bytes) falls in a range.                                                                                                                                            |
| `@IsCreditCard()`                                      | Checks if the string is a credit card.                                                                                                                                                                |
| `@IsCurrency(options?: IsCurrencyOptions)`             | Checks if the string is a valid currency amount.                                                                                                                                                      |
| `@IsISO4217CurrencyCode()`                             | Checks if the string is an ISO 4217 currency code.                                                                                                                                                    |
| `@IsEthereumAddress()`                                 | Checks if the string is an Ethereum address using basic regex. Does not validate address checksums.                                                                                                   |
| `@IsBtcAddress()`                                      | Checks if the string is a valid BTC address.                                                                                                                                                          |
| `@IsDataURI()`                                         | Checks if the string is a data uri format.                                                                                                                                                            |
| `@IsEmail(options?: IsEmailOptions)`                   | Checks if the string is an email.                                                                                                                                                                     |
| `@IsFQDN(options?: IsFQDNOptions)`                     | Checks if the string is a fully qualified domain name (e.g. domain.com).                                                                                                                              |
| `@IsFullWidth()`                                       | Checks if the string contains any full-width chars.                                                                                                                                                   |
| `@IsHalfWidth()`                                       | Checks if the string contains any half-width chars.                                                                                                                                                   |
| `@IsVariableWidth()`                                   | Checks if the string contains a mixture of full and half-width chars.                                                                                                                                 |
| `@IsHexColor()`                                        | Checks if the string is a hexadecimal color.                                                                                                                                                          |
| `@IsHSL()`                                             | Checks if the string is an HSL color based on [CSS Colors Level 4 specification](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value).                                                       |
| `@IsRgbColor(options?: IsRgbOptions)`                  | Checks if the string is a rgb or rgba color.                                                                                                                                                          |
| `@IsIdentityCard(locale?: string)`                     | Checks if the string is a valid identity card code.                                                                                                                                                   |
| `@IsPassportNumber(countryCode?: string)`              | Checks if the string is a valid passport number relative to a specific country code.                                                                                                                  |
| `@IsPostalCode(locale?: string)`                       | Checks if the string is a postal code.                                                                                                                                                                |
| `@IsHexadecimal()`                                     | Checks if the string is a hexadecimal number.                                                                                                                                                         |
| `@IsOctal()`                                           | Checks if the string is a octal number.                                                                                                                                                               |
| `@IsMACAddress(options?: IsMACAddressOptions)`         | Checks if the string is a MAC Address.                                                                                                                                                                |
| `@IsIP(version?: "4"\|"6")`                            | Checks if the string is an IP (version 4 or 6).                                                                                                                                                       |
| `@IsPort()`                                            | Checks if the string is a valid port number.                                                                                                                                                          |
| `@IsISBN(version?: "10"\|"13")`                        | Checks if the string is an ISBN (version 10 or 13).                                                                                                                                                   |
| `@IsEAN()`                                             | Checks if the string is an if the string is an EAN (European Article Number).                                                                                                                         |
| `@IsISIN()`                                            | Checks if the string is an ISIN (stock/security identifier).                                                                                                                                          |
| `@IsISO8601(options?: IsISO8601Options)`               | Checks if the string is a valid ISO 8601 date format. Use the option strict = true for additional checks for a valid date.                                                                            |
| `@IsJSON()`                                            | Checks if the string is valid JSON.                                                                                                                                                                   |
| `@IsJWT()`                                             | Checks if the string is valid JWT.                                                                                                                                                                    |
| `@IsObject()`                                          | Checks if the object is valid Object (null, functions, arrays will return false).                                                                                                                     |
| `@IsNotEmptyObject()`                                  | Checks if the object is not empty.                                                                                                                                                                    |
| `@IsLowercase()`                                       | Checks if the string is lowercase.                                                                                                                                                                    |
| `@IsLatLong()`                                         | Checks if the string is a valid latitude-longitude coordinate in the format lat, long.                                                                                                                |
| `@IsLatitude()`                                        | Checks if the string or number is a valid latitude coordinate.                                                                                                                                        |
| `@IsLongitude()`                                       | Checks if the string or number is a valid longitude coordinate.                                                                                                                                       |
| `@IsMobilePhone(locale: string)`                       | Checks if the string is a mobile phone number.                                                                                                                                                        |
| `@IsISO6391()`                                         | Checks if the string is a valid ISO 639-1 officially assigned language code.                                                                                                                          |
| `@IsISO31661Alpha2()`                                  | Checks if the string is a valid ISO 3166-1 alpha-2 officially assigned country code.                                                                                                                  |
| `@IsISO31661Alpha3()`                                  | Checks if the string is a valid ISO 3166-1 alpha-3 officially assigned country code.                                                                                                                  |
| `@IsISO31661Numeric()`                                 | Checks if the string is a valid ISO 3166-1 numeric officially assigned country code.                                                                                                                  |
| `@IsLocale()`                                          | Checks if the string is a locale.                                                                                                                                                                     |
| `@IsPhoneNumber(region: string)`                       | Checks if the string is a valid phone number using libphonenumber-js.                                                                                                                                 |
| `@IsMongoId()`                                         | Checks if the string is a valid hex-encoded representation of a MongoDB ObjectId.                                                                                                                     |
| `@IsMultibyte()`                                       | Checks if the string contains one or more multibyte chars.                                                                                                                                            |
| `@IsNumberString(options?: IsNumericOptions)`          | Checks if the string is numeric.                                                                                                                                                                      |
| `@IsSurrogatePair()`                                   | Checks if the string contains any surrogate pairs chars.                                                                                                                                              |
| `@IsTaxId()`                                           | Checks if the string is a valid tax ID. Default locale is `en-US`.                                                                                                                                    |
| `@IsUrl(options?: IsURLOptions)`                       | Checks if the string is a URL.                                                                                                                                                                        |
| `@IsMagnetURI()`                                       | Checks if the string is a [magnet uri format](https://en.wikipedia.org/wiki/Magnet_URI_scheme).                                                                                                       |
| `@IsUUID(version?: UUIDVersion)`                       | Checks if the string is a UUID (version 1-8, nil, max, loose, all). Also accepts array of versions.                                                                                                   |
| `@IsFirebasePushId()`                                  | Checks if the string is a [Firebase Push ID](https://firebase.googleblog.com/2015/02/the-2120-ways-to-ensure-unique_68.html)                                                                          |
| `@IsUppercase()`                                       | Checks if the string is uppercase.                                                                                                                                                                    |
| `@Length(min: number, max?: number)`                   | Checks if the string's length falls in a range.                                                                                                                                                       |
| `@MinLength(min: number)`                              | Checks if the string's length is not less than given number.                                                                                                                                          |
| `@MaxLength(max: number)`                              | Checks if the string's length is not more than given number.                                                                                                                                          |
| `@Matches(pattern: RegExp, modifiers?: string)`        | Checks if string matches the pattern. Either matches('foo', /foo/i) or matches('foo', 'foo', 'i').                                                                                                    |
| `@IsMilitaryTime()`                                    | Checks if the string is a valid representation of military time in the format HH:MM.                                                                                                                  |
| `@IsTimeZone()`                                        | Checks if the string represents a valid IANA time-zone.                                                                                                                                               |
| `@IsHash(algorithm: string)`                           | Checks if the string is a hash The following types are supported:`md4`, `md5`, `sha1`, `sha256`, `sha384`, `sha512`, `ripemd128`, `ripemd160`, `tiger128`, `tiger160`, `tiger192`, `crc32`, `crc32b`. |
| `@IsMimeType()`                                        | Checks if the string matches to a valid [MIME type](https://en.wikipedia.org/wiki/Media_type) format                                                                                                  |
| `@IsSemVer()`                                          | Checks if the string is a Semantic Versioning Specification (SemVer).                                                                                                                                 |
| `@IsISSN(options?: IsISSNOptions)`                     | Checks if the string is a ISSN.                                                                                                                                                                       |
| `@IsISRC()`                                            | Checks if the string is a [ISRC](https://en.wikipedia.org/wiki/International_Standard_Recording_Code).                                                                                                |
| `@IsRFC3339()`                                         | Checks if the string is a valid [RFC 3339](https://tools.ietf.org/html/rfc3339) date.                                                                                                                 |
| `@IsStrongPassword(options?: IsStrongPasswordOptions)` | Checks if the string is a strong password.                                                                                                                                                            |
| **Array validation decorators**                        |                                                                                                                                                                                                       |
| `@ArrayContains(values: any[])`                        | Checks if array contains all values from the given array of values.                                                                                                                                   |
| `@ArrayNotContains(values: any[])`                     | Checks if array does not contain any of the given values.                                                                                                                                             |
| `@ArrayNotEmpty()`                                     | Checks if given array is not empty.                                                                                                                                                                   |
| `@ArrayMinSize(min: number)`                           | Checks if the array's length is greater than or equal to the specified number.                                                                                                                        |
| `@ArrayMaxSize(max: number)`                           | Checks if the array's length is less or equal to the specified number.                                                                                                                                |
| `@ArrayUnique(identifier?: (o) => any)`                | Checks if all array's values are unique. Comparison for objects is reference-based. Optional function can be speciefied which return value will be used for the comparsion.                           |
| **Object validation decorators**                       |
| `@IsInstance(value: any)`                              | Checks if the property is an instance of the passed value.                                                                                                                                            |
| **Other decorators**                                   |                                                                                                                                                                                                       |
| `@Allow()`                                             | Prevent stripping off the property when no other constraint is specified for it.                                                                                                                      |

## Defining validation schema without decorators

Schema-based validation without decorators is no longer supported by `class-validator`. This feature was broken in version 0.12 and it will not be fixed. If you are interested in schema-based validation, you can find several such frameworks in [the zod readme's comparison section](https://github.com/colinhacks/zod#comparison).

## Validating plain objects

Due to nature of the decorators, the validated object has to be instantiated using `new Class()` syntax. If you have your class defined using class-validator decorators and you want to validate plain JS object (literal object or returned by JSON.parse), you need to transform it to the class instance via using [class-transformer](https://github.com/pleerock/class-transformer)).

## Samples

Take a look on samples in [./sample](https://github.com/pleerock/class-validator/tree/master/sample) for more examples of
usages.

## Extensions

There are several extensions that simplify class-validator integration with other modules or add additional validations:

- [class-validator integration](https://github.com/19majkel94/class-transformer-validator) with [class-transformer](https://github.com/pleerock/class-transformer)
- [class-validator-rule](https://github.com/yantrab/class-validator-rule)
- [ngx-dynamic-form-builder](https://github.com/EndyKaufman/ngx-dynamic-form-builder)
- [abarghoud/ngx-reactive-form-class-validator](https://github.com/abarghoud/ngx-reactive-form-class-validator)
- [class-validator-extended](https://github.com/pigulla/class-validator-extended)

## Release notes

See information about breaking changes and release notes [here][3].

[1]: https://github.com/chriso/validator.js
[2]: https://github.com/pleerock/typedi
[3]: CHANGELOG.md

## Contributing

For information about how to contribute to this project, see [TypeStack's general contribution guide](https://github.com/typestack/.github/blob/master/CONTRIBUTING.md).


================================================
FILE: codecov.yml
================================================
coverage:
  range: 70..100
  round: down
  precision: 2
  status:
    project:
      default:
        threshold: 0%
        paths: 
          - src/**/*.ts
comment: off
ignore:
  - testing/**/*.ts
  - src/**/*.interface.ts


================================================
FILE: docs/README.md
================================================
# Table of Contents

- [Read Me](../README.md)
- Getting Started
  - [Installation](introduction/installation.md)
  - [Usage with Typescript](introduction/usage-with-typescript.md)
  - [Usage with Javascript](introduction/usage-with-javascript.md)
  - [Dependency Injection](introduction/usage-with-di.md)
  - [Core Principes](introduction/core-principes.md)
- [Basic Usage](basics/README.md)
  - [Validating objects](basics/validating-objects.md)
  - [Validating arrays](basics/validating-arrays.md)
  - [Validating nested objects](basics/validating-nested-objects.md)
- [Advanced Usage](advanced/README.md)
  - [Conditional Validation](advanced/conditional-validation.md)
  - [Validation Groups](advanced/validation-groups.md)
  - [Inheritance](advanced/inheritance.md)
  - [Custom Validation Decorators](advanced/validations-decoratos.md)
  - [Custom Validation Classes](advanced/validation-classes.md)
- [Decorators Reference](reference/decoratos.md)
  - [Common Decorators](reference/common-decoratos.md)
  - [Number Decorators](reference/number-decoratos.md)
  - [String Decorators](reference/string-decoratos.md)
  - [Date Decorators](reference/date-decoratos.md)
  - [Array Decorators](reference/array-decoratos.md)
- [Recipes](recipes/README.md)
  - [Simple Validations](https://stackblitz.com/edit/class-transformer-simple-validations)
  - [Nested Objects](https://stackblitz.com/edit/class-transformer-nested-objects)
  - [Using Groups](https://stackblitz.com/edit/class-transformer-using-groups)
  - [Custom Validators](https://stackblitz.com/edit/class-transformer-custom-validator)
  - [Custom Decorators](https://stackblitz.com/edit/class-transformer-custom-decorators)
  - [Using Schemas](https://stackblitz.com/edit/class-transformer-schemas)
  - [Inheritance](https://stackblitz.com/edit/class-transformer-inheritance)
- [API Reference](api/README.md)
  - [validate](api/validate.md)
  - [ValidatorOptions ](api/ValidatorOptions.md)
  - [ValidationError ](api/ValidationError.md)
- [Change Log](../CHANGELOG.md)


================================================
FILE: docs/basics/validating-objects.md
================================================
# Validating objects

```ts
import {
  validate,
  validateOrReject,
  IsString,
  IsInt,
  IsDate,
  MaxLength,
  Min,
  Max,
  ValidationError,
} from 'class-validator';

export class Book {
  @IsString()
  @MaxLength(255)
  title: string;

  @IsString()
  @MaxLength(255)
  author: string;

  @IsInt()
  @Min(0)
  @Max(10)
  rating: number;

  @IsDate()
  publishDate: Date;
}

const book = new Book();
book.title = 'Don Quixote';
book.author = 'Miguel De Cervantes';
book.rating = 11;
book.publishDate = new Date();

validate(book).then((errors: ValidationError[]) => {
  if (errors.length > 0) {
    console.warn('validate() - Validation failed. Errors: ', errors);
  }
});

validateOrReject(book).catch((errors: ValidationError[]) => {
  console.warn('validateOrReject() - Validation failed. Errors: ', errors);
});

awaitExample();

async function awaitExample() {
  try {
    await validateOrReject(book);
  } catch (errors) {
    console.warn('Async validateOrReject() - Validation failed. Errors: ', errors);
  }
}
```

Run this example on [Stackblitz](https://stackblitz.com/edit/class-validator-simple-example-u9h1ve?file=index.ts)


================================================
FILE: docs/introduction/installation.md
================================================
# Installation

To install the stable version:

```
npm install --save class-validator
```

### Usage in the browser

If you want to use `class-validator` in the browser and you use Webpack then just import it into your project and Webpack will take care of the rest.

### Next version

You can install the next version of `class-validator` via

```
npm install --save class-validator@next
```

> Note: The next version can break anytime without notice. Do not use this in production.


================================================
FILE: jest.config.js
================================================
module.exports = {
  preset: 'ts-jest',
  testEnvironment: 'node',
  collectCoverageFrom: ['src/**/*.ts', '!src/**/index.ts', '!src/**/*.interface.ts'],
  globals: {
    'ts-jest': {
      tsconfig: 'tsconfig.spec.json',
    },
  },
};


================================================
FILE: package.json
================================================
{
  "name": "class-validator",
  "version": "0.15.1",
  "description": "Decorator-based property validation for classes.",
  "author": "TypeStack contributors",
  "license": "MIT",
  "sideEffects": false,
  "main": "./cjs/index.js",
  "module": "./esm5/index.js",
  "es2015": "./esm2015/index.js",
  "typings": "./types/index.d.ts",
  "repository": {
    "type": "git",
    "url": "https://github.com/typestack/class-validator.git"
  },
  "tags": [
    "validator",
    "validation",
    "decorators",
    "typescript"
  ],
  "scripts": {
    "build": "npm run build:cjs",
    "build:clean": "rimraf build",
    "build:es2015": "tsc --project tsconfig.prod.esm2015.json",
    "build:esm5": "tsc --project tsconfig.prod.esm5.json",
    "build:cjs": "tsc --project tsconfig.prod.cjs.json",
    "build:umd": "rollup --config rollup.config.js",
    "build:types": "tsc --project tsconfig.prod.types.json",
    "prettier:fix": "prettier --write \"**/*.{ts,md}\"",
    "prettier:check": "prettier --check \"**/*.{ts,md}\"",
    "lint:fix": "eslint --max-warnings 0 --fix --ext .ts src/",
    "lint:check": "eslint --max-warnings 0 --ext .ts src/",
    "test": "jest --coverage --verbose",
    "test:watch": "jest --watch",
    "test:ci": "jest --runInBand --no-cache --coverage --verbose"
  },
  "dependencies": {
    "@types/validator": "^13.15.3",
    "libphonenumber-js": "^1.11.1",
    "validator": "^13.15.22"
  },
  "devDependencies": {
    "@rollup/plugin-commonjs": "^25.0.7",
    "@rollup/plugin-node-resolve": "^15.2.3",
    "@types/jest": "^29.5.12",
    "@types/node": "^20.12.10",
    "@typescript-eslint/eslint-plugin": "^5.62.0",
    "@typescript-eslint/parser": "^5.62.0",
    "eslint": "^8.57.0",
    "eslint-config-prettier": "^9.1.0",
    "eslint-plugin-jest": "^27.9.0",
    "husky": "^4.3.8",
    "jest": "^29.7.0",
    "lint-staged": "^15.2.2",
    "prettier": "^2.8.8",
    "reflect-metadata": "0.2.2",
    "rimraf": "5.0.5",
    "rollup": "^2.79.1",
    "rollup-plugin-terser": "^7.0.2",
    "ts-jest": "^29.1.2",
    "ts-node": "^10.9.2",
    "typescript": "^5.4.5"
  }
}


================================================
FILE: rollup.config.js
================================================
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import { terser } from 'rollup-plugin-terser';

export default {
  input: 'build/esm5/index.js',
  output: [
    {
      name: 'ClassValidator',
      format: 'umd',
      file: 'build/bundles/class-validator.umd.js',
      sourcemap: true,
    },
    {
      name: 'ClassValidator',
      format: 'umd',
      file: 'build/bundles/class-validator.umd.min.js',
      sourcemap: true,
      plugins: [terser()],
    },
  ],
  plugins: [commonjs(), nodeResolve()],
};


================================================
FILE: sample/sample1-simple-validation/Post.ts
================================================
import {
  Contains,
  IsInt,
  MinLength,
  MaxLength,
  IsEmail,
  IsFQDN,
  IsDate,
  ArrayNotEmpty,
  ArrayMinSize,
  ArrayMaxSize,
  IsEnum,
} from '../../src/decorator/decorators';

export enum PostType {
  Public,
  Private,
}

export class Post {
  @MinLength(10)
  @MaxLength(20)
  title: string;

  @Contains('hello')
  text: string;

  @IsInt()
  rating: number;

  @IsEmail()
  email: string;

  @IsFQDN()
  site: string;

  @IsDate()
  createDate: Date;

  @ArrayNotEmpty()
  @ArrayMinSize(2)
  @ArrayMaxSize(5)
  @MinLength(3, { each: true, message: 'Tag is too short. Minimal length is $value characters' })
  @MaxLength(50, { each: true, message: 'Tag is too long. Maximal length is $value characters' })
  tags: string[];

  @IsEnum(PostType)
  type: PostType;
}


================================================
FILE: sample/sample1-simple-validation/app.ts
================================================
import { validate } from '../../src/index';
import { Post, PostType } from './Post';

// Sample1. simple validation

let post1 = new Post();
post1.title = 'Hello world'; // should pass
post1.text = 'this is a great post about hello world'; // should pass
post1.rating = 10; // should pass
post1.email = 'info@google.com'; // should pass
post1.site = 'google.com'; // should pass
post1.createDate = new Date(); // should pass
post1.tags = ['abcd1', 'abcd2', 'abcd3', 'abcd4', 'abcd4']; // should pass
post1.type = PostType.Private;

validate(post1).then(result => {
  console.log('1. should pass: ', result); // should pass completely, e.g. return empty array
});

let post2 = new Post();
post2.title = 'Hello'; // should not pass
post2.text = 'this is a great post about hell world'; // should not pass
post2.rating = 1.1; // should not pass
post2.email = 'google.com'; // should not pass
post2.site = 'googlecom'; // should not pass
post2.type = PostType.Private; // should pass

// should not pass because date property is missing
validate(post2).then(result => {
  console.log('2. should not pass: ', result); // should not pass completely, must return array of ValidationError-s
});

// Sample2. using validation options to skip properties that are not defined

let post3 = new Post();
post3.title = 'Hello'; // should not pass
post3.text = 'this is a great post about hell world'; // should not pass
post3.rating = 1.1; // should not pass
post3.email = 'google.com'; // should not pass
post3.site = 'googlecom'; // should not pass
post3.type = PostType.Private;

validate(post3, { skipMissingProperties: true }).then(result => {
  console.log('3. should not pass: ', result); // should not pass, but returned ValidationError-s should not have error about date field
});

let post4 = new Post();
post4.title = 'Hello world'; // should pass
post4.text = 'this is a great post about hello world'; // should pass
post4.rating = 10; // should pass
post4.email = 'info@google.com'; // should pass
post4.site = 'google.com'; // should pass
post4.type = PostType.Private;

validate(post4, { skipMissingProperties: true }).then(result => {
  console.log('4. should pass: ', result); // should pass even if date is not set
});

// Sample3. using validation groups

let post5 = new Post();
post5.title = 'Hello world'; // should pass
post5.text = 'this is a great post about hello world'; // should pass
post5.rating = 10; // should pass
post5.email = 'info@google.com'; // should pass
post5.site = 'google.com'; // should pass
post5.type = PostType.Private;

validate(post5, { skipMissingProperties: true }).then(result => {
  console.log('5. should pass: ', result); // should pass even if date is not set
});

// Sample4. array validation

let post6 = new Post();
post6.title = 'Hello world'; // should pass
post6.text = 'this is a great post about hello world'; // should pass
post6.rating = 10; // should pass
post6.email = 'info@google.com'; // should pass
post6.site = 'google.com'; // should pass
post6.createDate = new Date(); // should pass
post6.tags = ['abcd1', 'abcd2', 'abcd3', 'abcd4', 'abcd4'];
post6.type = PostType.Private;

validate(post6).then(result => {
  console.log('6. should pass: ', result); // should pass completely, e.g. return empty array
});

let post7 = new Post();
post7.title = 'Hello world'; // should pass
post7.text = 'this is a great post about hello world'; // should pass
post7.rating = 10; // should pass
post7.email = 'info@google.com'; // should pass
post7.site = 'google.com'; // should pass
post7.createDate = new Date(); // should pass
post7.tags = ['news', 'a'];
post7.type = PostType.Private;

validate(post7).then(result => {
  console.log('7. should not pass: ', result); // should not pass
});

let post8 = new Post();
post8.title = 'Hello world'; // should pass
post8.text = 'this is a great post about hello world'; // should pass
post8.rating = 10; // should pass
post8.email = 'info@google.com'; // should pass
post8.site = 'google.com'; // should pass
post8.createDate = new Date(); // should pass
post8.tags = [];
post8.type = PostType.Private;

validate(post8).then(result => {
  console.log('8. should not pass: ', result); // should not pass
});

let post9 = new Post();
post9.title = 'Hello world'; // should pass
post9.text = 'this is a great post about hello world'; // should pass
post9.rating = 10; // should pass
post9.email = 'info@google.com'; // should pass
post9.site = 'google.com'; // should pass
post9.createDate = new Date(); // should pass
post9.tags = ['abcd1', 'abcd2', 'abcd3', 'abcd4', 'abcd4', 'abcd4'];
post9.type = PostType.Private;

validate(post9).then(result => {
  console.log('9. should not pass: ', result); // should not pass
});

let post10 = new Post();
post10.title = 'Hello world'; // should pass
post10.text = 'this is a great post about hello world'; // should pass
post10.rating = 10; // should pass
post10.email = 'info@google.com'; // should pass
post10.site = 'google.com'; // should pass
post10.createDate = new Date(); // should pass
post10.tags = ['abcd1', 'abcd2', 'abcd3', 'abcd4', 'abcd4'];
post10.type = PostType.Private;

validate(post10).then(result => {
  console.log('10. should pass: ', result); // should pass
});

let post11 = new Post();
post11.title = 'Hello world'; // should pass
post11.text = 'this is a great post about hello world'; // should pass
post11.rating = 10; // should pass
post11.email = 'info@google.com'; // should pass
post11.site = 'google.com'; // should pass
post11.createDate = new Date(); // should pass
post11.tags = null;
post11.type = PostType.Private;

validate(post11).then(result => {
  console.log('11. should not pass: ', result); // should not pass
});

let post12 = new Post();
post12.title = 'Hello world'; // should pass
post12.text = 'this is a great post about hello world'; // should pass
post12.rating = 10; // should pass
post12.email = 'info@google.com'; // should pass
post12.site = 'google.com'; // should pass
post12.createDate = new Date(); // should pass
post12.tags = ['abcd1', 'abcd2', 'abcd3', 'abcd4', 'abcd4']; // should pass
post12.type = 99; // should not pass

validate(post1).then(result => {
  console.log('12. should not pass: ', result); // should not pass as type is not a valid enum
});


================================================
FILE: sample/sample2-using-groups/Post.ts
================================================
import { Contains, IsInt, Length, IsEmail, IsFQDN, IsDate } from '../../src/decorator/decorators';

export class Post {
  @Length(10, 20, {
    message: 'Incorrect length!',
    groups: ['users', 'moderators'],
  })
  @Length(0, 20, {
    message: 'Incorrect length!',
    groups: ['admins'],
  })
  title: string;

  @Contains('hello', {
    message: 'It should contain word "hello!"',
    groups: ['users', 'moderators'],
  })
  text: string;

  @IsInt()
  rating: number;

  @IsEmail(undefined, {
    always: true,
  })
  email: string;

  @IsFQDN(undefined, {
    message: 'Site address should be correct',
    groups: ['users'],
  })
  site: string;

  @IsDate()
  createDate: Date;
}


================================================
FILE: sample/sample2-using-groups/app.ts
================================================
import { Validator } from '../../src/validation/Validator';
import { Post } from './Post';

let validator = new Validator();

let post1 = new Post();
post1.title = 'Hello world'; // should pass
post1.text = 'this is a great post about hello world'; // should pass
post1.rating = 10; // should pass
post1.email = 'info@google.com'; // should pass
post1.site = 'google.com'; // should pass
post1.createDate = new Date(); // should pass

validator.validate(post1, { groups: ['users'] }).then(result => {
  console.log('1.1. should pass: ', result);
});

validator.validate(post1, { groups: ['admins'] }).then(result => {
  console.log('1.2. should pass: ', result);
});

let post2 = new Post();
post2.title = 'Hi!'; // should not pass for user or moderator, but should pass for admin
post2.text = 'this is a great post about hello world'; // should pass
post2.rating = 10; // should pass
post2.email = 'info@google.com'; // should pass
post2.site = 'google.com'; // should pass
post2.createDate = new Date(); // should pass

validator.validate(post2, { groups: ['users'] }).then(result => {
  console.log('2.1. should not pass: ', result);
});

validator.validate(post2, { groups: ['moderators'] }).then(result => {
  console.log('2.2. should not pass: ', result);
});

validator.validate(post2, { groups: ['admins'] }).then(result => {
  console.log('2.3. should pass: ', result);
});

validator.validate(post2, { groups: ['users', 'admins'] }).then(result => {
  console.log('2.4. should not pass: ', result);
});

let post3 = new Post();
post3.title = 'Hello world'; // should not pass for user or moderator, but should pass for admin
post3.text = 'this is a great post about hello world'; // should pass
post3.rating = 10; // should pass
post3.email = 'info@google.com'; // should pass
post3.site = 'google.com'; // should pass
// note that we dont set date

validator.validate(post3, { groups: ['users'] }).then(result => {
  console.log('3.1. should pass: ', result);
});

validator.validate(post3).then(result => {
  console.log('3.2. should not pass: ', result);
});

let post4 = new Post();
post4.title = 'Hello world'; // should not pass for user or moderator, but should pass for admin
post4.text = 'this is a great post about hello world'; // should pass
post4.rating = 10; // should pass
post4.email = ''; // should not pass
post4.site = 'google.com'; // should pass
// note that we dont set date

validator.validate(post4, { groups: ['users'] }).then(result => {
  console.log('4.1. should not pass: ', result);
});

validator.validate(post4).then(result => {
  console.log('4.2. should not pass: ', result);
});


================================================
FILE: sample/sample3-nested-objects/Post.ts
================================================
import { Contains, IsInt, Length, IsEmail, IsFQDN, IsDate, ValidateNested } from '../../src/decorator/decorators';
import { Tag } from './Tag';

export class Post {
  @Length(10, 20, {
    message: 'Incorrect length!',
  })
  title: string;

  @ValidateNested()
  tags: Tag[];
}


================================================
FILE: sample/sample3-nested-objects/Tag.ts
================================================
import { Contains, IsInt, Length, IsEmail, IsFQDN, IsDate } from '../../src/decorator/decorators';

export class Tag {
  @Length(10, 20, {
    message: 'Tag is too short or long',
  })
  name: string;
}


================================================
FILE: sample/sample3-nested-objects/app.ts
================================================
import { Validator } from '../../src/validation/Validator';
import { Post } from './Post';
import { Tag } from './Tag';

let validator = new Validator();

let tag1 = new Tag();
tag1.name = 'ja';

let tag2 = new Tag();
tag2.name = 'node.js';

let post1 = new Post();
post1.title = 'Hello world';
post1.tags = [tag1, tag2];

validator.validate(post1).then(result => {
  console.log('1. should not pass: ', result);
});


================================================
FILE: sample/sample4-custom-validator/CustomTextLength.ts
================================================
import { ValidatorConstraintInterface } from '../../src/validation/ValidatorConstraintInterface';
import { ValidatorConstraint } from '../../src/decorator/decorators';

@ValidatorConstraint()
export class CustomTextLength implements ValidatorConstraintInterface {
  validate(text: string) {
    return text.length > 1 && text.length < 10;
  }
}


================================================
FILE: sample/sample4-custom-validator/Post.ts
================================================
import {
  Contains,
  IsInt,
  MinLength,
  MaxLength,
  IsEmail,
  IsFQDN,
  IsDate,
  IsNotEmpty,
  ArrayNotEmpty,
  ArrayMinSize,
  ArrayMaxSize,
} from '../../src/decorator/decorators';
import { Validate } from '../../src/decorator/decorators';
import { CustomTextLength } from './CustomTextLength';

export class Post {
  @Validate(CustomTextLength, {
    message: 'Wrong post title',
  })
  title: string;
}


================================================
FILE: sample/sample4-custom-validator/app.ts
================================================
import { Validator } from '../../src/validation/Validator';
import { Post } from './Post';

let validator = new Validator();

let post1 = new Post();
post1.title = 'Hello world';

validator.validate(post1).then(result => {
  console.log('1. should not pass: ', result);
});

let post2 = new Post();
post2.title = 'Hello !!!';

validator.validate(post2).then(result => {
  console.log('2. should pass: ', result);
});


================================================
FILE: sample/sample5-schemas/Post.ts
================================================
export class Post {
  title: string;
  text: string;
  rating: number;
  email: string;
  site: string;
  createDate: Date;
  tags: string[];
}


================================================
FILE: sample/sample5-schemas/app.ts
================================================
import { validate, registerSchema } from '../../src/index';
import { Post } from './Post';

// load schema. we load it a bit tricky way because we output source code into separate directory, so our json resource left in another directory
const postSchema = require(__dirname + '/../../../../sample/sample5-schemas/post.json');

// register this schema
registerSchema(postSchema);

// Sample1. simple validation

let post1 = new Post();
post1.title = 'Hello world'; // should pass
post1.text = 'this is a great post about hello world'; // should pass
post1.rating = 10; // should pass
post1.email = 'info@google.com'; // should pass
post1.site = 'google.com'; // should pass
post1.createDate = new Date(); // should pass
post1.tags = ['abcd1', 'abcd2', 'abcd3', 'abcd4', 'abcd4']; // should pass

validate('post', post1).then(result => {
  console.log('1. should pass: ', result); // should pass completely, e.g. return empty array
});

let post2 = new Post();
post2.title = 'Hello'; // should not pass
post2.text = 'this is a great post about hell world'; // should not pass
post2.rating = 11; // should not pass
post2.email = 'google.com'; // should not pass
post2.site = 'googlecom'; // should not pass
// should not pass because date property is missing

validate('post', post2).then(result => {
  console.log('2. should not pass: ', result); // should not pass completely, must return array of ValidationError-s
});

// Sample2. using validation options to skip properties that are not defined

let post3 = new Post();
post3.title = 'Hello'; // should not pass
post3.text = 'this is a great post about hell world'; // should not pass
post3.rating = 11; // should not pass
post3.email = 'google.com'; // should not pass
post3.site = 'googlecom'; // should not pass

validate('post', post3, { skipMissingProperties: true }).then(result => {
  console.log('3. should not pass: ', result); // should not pass, but returned ValidationError-s should not have error about date field
});

let post4 = new Post();
post4.title = 'Hello world'; // should pass
post4.text = 'this is a great post about hello world'; // should pass
post4.rating = 10; // should pass
post4.email = 'info@google.com'; // should pass
post4.site = 'google.com'; // should pass

validate('post', post4, { skipMissingProperties: true }).then(result => {
  console.log('4. should pass: ', result); // should pass even if date is not set
});

// Sample3. using validation groups

let post5 = new Post();
post5.title = 'Hello world'; // should pass
post5.text = 'this is a great post about hello world'; // should pass
post5.rating = 10; // should pass
post5.email = 'info@google.com'; // should pass
post5.site = 'google.com'; // should pass

validate('post', post5, { skipMissingProperties: true }).then(result => {
  console.log('5. should pass: ', result); // should pass even if date is not set
});

// Sample4. array validation

let post6 = new Post();
post6.title = 'Hello world'; // should pass
post6.text = 'this is a great post about hello world'; // should pass
post6.rating = 10; // should pass
post6.email = 'info@google.com'; // should pass
post6.site = 'google.com'; // should pass
post6.createDate = new Date(); // should pass
post6.tags = ['abcd1', 'abcd2', 'abcd3', 'abcd4', 'abcd4'];

validate('post', post6).then(result => {
  console.log('6. should pass: ', result); // should pass completely, e.g. return empty array
});

let post7 = new Post();
post7.title = 'Hello world'; // should pass
post7.text = 'this is a great post about hello world'; // should pass
post7.rating = 10; // should pass
post7.email = 'info@google.com'; // should pass
post7.site = 'google.com'; // should pass
post7.createDate = new Date(); // should pass
post7.tags = ['news', 'a'];

validate('post', post7).then(result => {
  console.log('7. should not pass: ', result); // should not pass
});

let post8 = new Post();
post8.title = 'Hello world'; // should pass
post8.text = 'this is a great post about hello world'; // should pass
post8.rating = 10; // should pass
post8.email = 'info@google.com'; // should pass
post8.site = 'google.com'; // should pass
post8.createDate = new Date(); // should pass
post8.tags = [];

validate('post', post8).then(result => {
  console.log('8. should not pass: ', result); // should not pass
});

let post9 = new Post();
post9.title = 'Hello world'; // should pass
post9.text = 'this is a great post about hello world'; // should pass
post9.rating = 10; // should pass
post9.email = 'info@google.com'; // should pass
post9.site = 'google.com'; // should pass
post9.createDate = new Date(); // should pass
post9.tags = ['a', 'abcd1', 'abcd2', 'abcd3', 'abcd4', 'abcd4', 'abcd4'];

validate('post', post9).then(result => {
  console.log('9. should not pass: ', result); // should not pass
});

let post10 = new Post();
post10.title = 'Hello world'; // should pass
post10.text = 'this is a great post about hello world'; // should pass
post10.rating = 10; // should pass
post10.email = 'info@google.com'; // should pass
post10.site = 'google.com'; // should pass
post10.createDate = new Date(); // should pass
post10.tags = ['abcd1', 'abcd2', 'abcd3', 'abcd4', 'abcd4'];

validate('post', post10).then(result => {
  console.log('10. should pass: ', result); // should pass
});

let post11 = new Post();
post11.title = 'Hello world'; // should pass
post11.text = 'this is a great post about hello world'; // should pass
post11.rating = 10; // should pass
post11.email = 'info@google.com'; // should pass
post11.site = 'google.com'; // should pass
post11.createDate = new Date(); // should pass
post11.tags = null;

validate('post', post11).then(result => {
  console.log('11. should not pass: ', result); // should not pass
});


================================================
FILE: sample/sample5-schemas/post.json
================================================
{
  "name": "post",
  "properties": {
    "title": [{
      "type": "minLength",
      "constraints": [10]
    },
    {
      "type": "maxLength",
      "constraints": [20]
    }],
    "text": [{
      "type": "contains",
      "constraints": ["hello"]
    }],
    "rating": [{
      "type": "isInt"
    }],
    "email": [{
      "type": "isEmail"
    }],
    "site": [{
      "type": "isFqdn"
    }],
    "createDate": [{
      "type": "isDate"
    }],
    "tags": [{
      "type": "arrayNotEmpty"
    },
    {
      "type": "arrayMinSize",
      "constraints": [2]
    },
    {
      "type": "arrayMaxSize",
      "constraints": [5]
    },
    {
      "type": "minLength",
      "each": true,
      "constraints": [3],
      "message": "Tag is too short. Minimal length is $constraint1 characters"
    },
    {
      "type": "maxLength",
      "each": true,
      "constraints": [50],
      "message": "Tag is too long. Maximal length is $constraint1 characters"
    }]
  }
}

================================================
FILE: sample/sample6-custom-decorator/IsLongerThan.ts
================================================
import { registerDecorator } from '../../src/index';
import { ValidationOptions } from '../../src/decorator/ValidationOptions';
import { ValidatorConstraintInterface } from '../../src/validation/ValidatorConstraintInterface';
import { ValidatorConstraint } from '../../src/decorator/decorators';
import { ValidationArguments } from '../../src/validation/ValidationArguments';

export function IsLongerThan(property: string, validationOptions?: ValidationOptions) {
  return function (object: Object, propertyName: string) {
    registerDecorator({
      target: object.constructor,
      propertyName: propertyName,
      options: validationOptions,
      constraints: [property],
      validator: IsLongerThanConstraint,
    });
  };
}

@ValidatorConstraint({ name: 'isLongerThan' })
export class IsLongerThanConstraint implements ValidatorConstraintInterface {
  validate(value: any, args: ValidationArguments) {
    const [relatedPropertyName] = args.constraints;
    const relatedValue = (args.object as any)[relatedPropertyName];
    return typeof value === 'string' && typeof relatedValue === 'string' && value.length > relatedValue.length;
  }
}


================================================
FILE: sample/sample6-custom-decorator/IsUserAlreadyExist.ts
================================================
import { registerDecorator } from '../../src/index';
import { ValidationOptions } from '../../src/decorator/ValidationOptions';
import { ValidationArguments } from '../../src/validation/ValidationArguments';

export function IsUserAlreadyExist(validationOptions?: ValidationOptions) {
  return function (object: Object, propertyName: string) {
    registerDecorator({
      name: 'isUserAlreadyExist',
      async: true,
      target: object.constructor,
      propertyName: propertyName,
      options: validationOptions,
      validator: {
        validate(value: any, args: ValidationArguments) {
          return new Promise(ok => {
            if (value !== 'admin' && value !== 'user') {
              ok(true);
            } else {
              ok(false);
            }
          });
        },
      },
    });
  };
}


================================================
FILE: sample/sample6-custom-decorator/User.ts
================================================
import { IsUserAlreadyExist } from './IsUserAlreadyExist';
import { IsLongerThan } from './IsLongerThan';

export class User {
  @IsUserAlreadyExist({
    message: 'User with name $value already exists',
  })
  firstName: string;

  @IsLongerThan('firstName', {
    message: "User's last name must be longer than firstName",
  })
  lastName: string;
}


================================================
FILE: sample/sample6-custom-decorator/app.ts
================================================
import { Validator } from '../../src/validation/Validator';
import { User } from './User';

let validator = new Validator();

let user1 = new User();
user1.firstName = 'Umed';

validator.validate(user1, { skipMissingProperties: true }).then(result => {
  console.log('1. should pass: ', result);
});

let user2 = new User();
user2.firstName = 'admin';

validator.validate(user2, { skipMissingProperties: true }).then(result => {
  console.log('2. should not pass: ', result);
});

let user3 = new User();
user3.firstName = 'user';

validator.validate(user3, { skipMissingProperties: true }).then(result => {
  console.log('3. should not pass: ', result);
});

let user4 = new User();
user4.firstName = 'Zak';
user4.lastName = 'Henry';

validator.validate(user4).then(result => {
  console.log('4. should pass: ', result);
});

let user5 = new User();
user5.firstName = 'Henry';
user5.lastName = 'Zak';

validator.validate(user5).then(result => {
  console.log('5. should not pass: ', result);
});


================================================
FILE: sample/sample7-inheritance-support/BaseContent.ts
================================================
import { IsEmail } from '../../src/decorator/decorators';

export class BaseContent {
  @IsEmail()
  email: string;
}


================================================
FILE: sample/sample7-inheritance-support/Post.ts
================================================
import { Contains, IsInt, MinLength, MaxLength } from '../../src/decorator/decorators';
import { BaseContent } from './BaseContent';

export class Post extends BaseContent {
  @MinLength(10)
  @MaxLength(20)
  title: string;

  @Contains('hello')
  text: string;

  @IsInt()
  rating: number;
}


================================================
FILE: sample/sample7-inheritance-support/app.ts
================================================
import { validate } from '../../src/index';
import { Post } from './Post';

// Sample1. simple validation

let post1 = new Post();
post1.title = 'Hello world'; // should pass
post1.text = 'this is a great post about hello world'; // should pass
post1.rating = 10; // should pass
post1.email = '@google.com'; // should not pass

validate(post1).then(result => {
  console.log('1. should not pass: ', result); // should not pass completely
});


================================================
FILE: sample/sample8-es6-maps/Post.ts
================================================
import { Contains, IsInt, Length, IsEmail, IsFQDN, IsDate, ValidateNested } from '../../src/decorator/decorators';
import { Tag } from './Tag';

export class Post {
  @Length(10, 20, {
    message: 'Incorrect length!',
  })
  title: string;

  @ValidateNested()
  tags: Map<string, Tag>;
}


================================================
FILE: sample/sample8-es6-maps/Tag.ts
================================================
import { Contains, IsInt, Length, IsEmail, IsFQDN, IsDate } from '../../src/decorator/decorators';

export class Tag {
  @Length(10, 20, {
    message: 'Tag value is too short or long',
  })
  value: string;
}


================================================
FILE: sample/sample8-es6-maps/app.ts
================================================
import { Validator } from '../../src/validation/Validator';
import { Post } from './Post';
import { Tag } from './Tag';

let validator = new Validator();

let tag1 = new Tag();
tag1.value = 'ja';

let tag2 = new Tag();
tag2.value = 'node.js';

let post1 = new Post();
post1.title = 'Hello world';
post1.tags = new Map();
post1.tags.set('tag1', tag1);
post1.tags.set('tag2', tag2);

validator.validate(post1).then(result => {
  console.log('1. should not pass: ', result);
});


================================================
FILE: sample/sample9-es6-sets/Post.ts
================================================
import { Contains, IsInt, Length, IsEmail, IsFQDN, IsDate, ValidateNested } from '../../src/decorator/decorators';
import { Tag } from './Tag';

export class Post {
  @Length(10, 20, {
    message: 'Incorrect length!',
  })
  title: string;

  @ValidateNested()
  tags: Set<Tag>;
}


================================================
FILE: sample/sample9-es6-sets/Tag.ts
================================================
import { Contains, IsInt, Length, IsEmail, IsFQDN, IsDate } from '../../src/decorator/decorators';

export class Tag {
  @Length(10, 20, {
    message: 'Tag value is too short or long',
  })
  value: string;
}


================================================
FILE: sample/sample9-es6-sets/app.ts
================================================
import { Validator } from '../../src/validation/Validator';
import { Post } from './Post';
import { Tag } from './Tag';

let validator = new Validator();

let tag1 = new Tag();
tag1.value = 'ja';

let tag2 = new Tag();
tag2.value = 'node.js';

let post1 = new Post();
post1.title = 'Hello world';
post1.tags = new Set();
post1.tags.add(tag1);
post1.tags.add(tag2);

validator.validate(post1).then(result => {
  console.log('1. should not pass: ', result);
});


================================================
FILE: src/container.ts
================================================
/**
 * Container options.
 */
export interface UseContainerOptions {
  /**
   * If set to true, then default container will be used in the case if given container haven't returned anything.
   */
  fallback?: boolean;

  /**
   * If set to true, then default container will be used in the case if given container thrown an exception.
   */
  fallbackOnErrors?: boolean;
}

/**
 * Container to be used by this library for inversion control. If container was not implicitly set then by default
 * container simply creates a new instance of the given class.
 */
const defaultContainer: { get<T>(someClass: { new (...args: any[]): T } | Function): T } = new (class {
  private instances: { type: Function; object: any }[] = [];
  get<T>(someClass: { new (...args: any[]): T }): T {
    let instance = this.instances.find(instance => instance.type === someClass);
    if (!instance) {
      instance = { type: someClass, object: new someClass() };
      this.instances.push(instance);
    }

    return instance.object;
  }
})();

let userContainer: { get<T>(someClass: { new (...args: any[]): T } | Function): T };
let userContainerOptions: UseContainerOptions;

/**
 * Sets container to be used by this library.
 */
export function useContainer(iocContainer: { get(someClass: any): any }, options?: UseContainerOptions): void {
  userContainer = iocContainer;
  userContainerOptions = options;
}

/**
 * Gets the IOC container used by this library.
 */
export function getFromContainer<T>(someClass: { new (...args: any[]): T } | Function): T {
  if (userContainer) {
    try {
      const instance = userContainer.get(someClass);
      if (instance) return instance;

      if (!userContainerOptions || !userContainerOptions.fallback) return instance;
    } catch (error) {
      if (!userContainerOptions || !userContainerOptions.fallbackOnErrors) throw error;
    }
  }
  return defaultContainer.get<T>(someClass);
}


================================================
FILE: src/decorator/ValidationOptions.ts
================================================
import { ValidationArguments } from '../validation/ValidationArguments';

/**
 * Options used to pass to validation decorators.
 */
export interface ValidationOptions {
  /**
   * Specifies if validated value is an array and each of its items must be validated.
   */
  each?: boolean;

  /**
   * Error message to be used on validation fail.
   * Message can be either string or a function that returns a string.
   */
  message?: string | ((validationArguments: ValidationArguments) => string);

  /**
   * Validation groups used for this validation.
   */
  groups?: string[];

  /**
   * Indicates if validation must be performed always, no matter of validation groups used.
   */
  always?: boolean;

  /*
   * A transient set of data passed through to the validation result for response mapping
   */
  context?: any;

  /**
   * validation will be performed while the result is true
   */
  validateIf?: (object: any, value: any) => boolean;
}

export function isValidationOptions(val: any): val is ValidationOptions {
  if (!val) {
    return false;
  }
  return (
    'each' in val || 'message' in val || 'groups' in val || 'always' in val || 'context' in val || 'validateIf' in val
  );
}


================================================
FILE: src/decorator/array/ArrayContains.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';

export const ARRAY_CONTAINS = 'arrayContains';

/**
 * Checks if array contains all values from the given array of values.
 * If null or undefined is given then this function returns false.
 */
export function arrayContains(array: unknown, values: any[]): boolean {
  if (!Array.isArray(array)) return false;

  return values.every(value => array.indexOf(value) !== -1);
}

/**
 * Checks if array contains all values from the given array of values.
 * If null or undefined is given then this function returns false.
 */
export function ArrayContains(values: any[], validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: ARRAY_CONTAINS,
      constraints: [values],
      validator: {
        validate: (value, args): boolean => arrayContains(value, args?.constraints[0]),
        defaultMessage: buildMessage(
          eachPrefix => eachPrefix + '$property must contain $constraint1 values',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/array/ArrayMaxSize.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';

export const ARRAY_MAX_SIZE = 'arrayMaxSize';

/**
 * 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.
 */
export function arrayMaxSize(array: unknown, max: number): boolean {
  return Array.isArray(array) && array.length <= max;
}

/**
 * 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.
 */
export function ArrayMaxSize(max: number, validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: ARRAY_MAX_SIZE,
      constraints: [max],
      validator: {
        validate: (value, args): boolean => arrayMaxSize(value, args?.constraints[0]),
        defaultMessage: buildMessage(
          eachPrefix => eachPrefix + '$property must contain no more than $constraint1 elements',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/array/ArrayMinSize.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';

export const ARRAY_MIN_SIZE = 'arrayMinSize';

/**
 * 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.
 */
export function arrayMinSize(array: unknown, min: number): boolean {
  return Array.isArray(array) && array.length >= min;
}

/**
 * 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.
 */
export function ArrayMinSize(min: number, validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: ARRAY_MIN_SIZE,
      constraints: [min],
      validator: {
        validate: (value, args): boolean => arrayMinSize(value, args?.constraints[0]),
        defaultMessage: buildMessage(
          eachPrefix => eachPrefix + '$property must contain at least $constraint1 elements',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/array/ArrayNotContains.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';

export const ARRAY_NOT_CONTAINS = 'arrayNotContains';

/**
 * Checks if array does not contain any of the given values.
 * If null or undefined is given then this function returns false.
 */
export function arrayNotContains(array: unknown, values: any[]): boolean {
  if (!Array.isArray(array)) return false;

  return values.every(value => array.indexOf(value) === -1);
}

/**
 * Checks if array does not contain any of the given values.
 * If null or undefined is given then this function returns false.
 */
export function ArrayNotContains(values: any[], validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: ARRAY_NOT_CONTAINS,
      constraints: [values],
      validator: {
        validate: (value, args): boolean => arrayNotContains(value, args?.constraints[0]),
        defaultMessage: buildMessage(
          eachPrefix => eachPrefix + '$property should not contain $constraint1 values',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/array/ArrayNotEmpty.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';

export const ARRAY_NOT_EMPTY = 'arrayNotEmpty';

/**
 * Checks if given array is not empty.
 * If null or undefined is given then this function returns false.
 */
export function arrayNotEmpty(array: unknown): boolean {
  return Array.isArray(array) && array.length > 0;
}

/**
 * Checks if given array is not empty.
 * If null or undefined is given then this function returns false.
 */
export function ArrayNotEmpty(validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: ARRAY_NOT_EMPTY,
      validator: {
        validate: (value, args): boolean => arrayNotEmpty(value),
        defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property should not be empty', validationOptions),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/array/ArrayUnique.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';

export const ARRAY_UNIQUE = 'arrayUnique';
export type ArrayUniqueIdentifier<T = any> = (o: T) => any;

/**
 * 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.
 */
export function arrayUnique(array: unknown[], identifier?: ArrayUniqueIdentifier): boolean {
  if (!Array.isArray(array)) return false;

  if (identifier) {
    array = array.map(o => (o != null ? identifier(o) : o));
  }

  const uniqueItems = array.filter((a, b, c) => c.indexOf(a) === b);
  return array.length === uniqueItems.length;
}

/**
 * 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.
 */
export function ArrayUnique<T = any>(
  identifierOrOptions?: ArrayUniqueIdentifier<T> | ValidationOptions,
  validationOptions?: ValidationOptions
): PropertyDecorator {
  const identifier = typeof identifierOrOptions === 'function' ? identifierOrOptions : undefined;
  const options = typeof identifierOrOptions !== 'function' ? identifierOrOptions : validationOptions;

  return ValidateBy(
    {
      name: ARRAY_UNIQUE,
      validator: {
        validate: (value, args): boolean => arrayUnique(value, identifier),
        defaultMessage: buildMessage(eachPrefix => eachPrefix + "All $property's elements must be unique", options),
      },
    },
    options
  );
}


================================================
FILE: src/decorator/common/Allow.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { ValidationMetadataArgs } from '../../metadata/ValidationMetadataArgs';
import { ValidationTypes } from '../../validation/ValidationTypes';
import { ValidationMetadata } from '../../metadata/ValidationMetadata';
import { getMetadataStorage } from '../../metadata/MetadataStorage';

/**
 * If object has both allowed and not allowed properties a validation error will be thrown.
 */
export function Allow(validationOptions?: ValidationOptions): PropertyDecorator {
  return function (object: object, propertyName: string): void {
    const args: ValidationMetadataArgs = {
      type: ValidationTypes.WHITELIST,
      target: object.constructor,
      propertyName: propertyName,
      validationOptions: validationOptions,
    };
    getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
  };
}


================================================
FILE: src/decorator/common/Equals.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';

export const EQUALS = 'equals';

/**
 * Checks if value matches ("===") the comparison.
 */
export function equals(value: unknown, comparison: unknown): boolean {
  return value === comparison;
}

/**
 * Checks if value matches ("===") the comparison.
 */
export function Equals(comparison: any, validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: EQUALS,
      constraints: [comparison],
      validator: {
        validate: (value, args): boolean => equals(value, args?.constraints[0]),
        defaultMessage: buildMessage(
          eachPrefix => eachPrefix + '$property must be equal to $constraint1',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/common/IsDefined.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from './ValidateBy';
import { ValidationTypes } from '../../validation/ValidationTypes';

// isDefined is (yet) a special case
export const IS_DEFINED = ValidationTypes.IS_DEFINED;

/**
 * Checks if value is defined (!== undefined, !== null).
 */
export function isDefined<T>(value: T | undefined | null): value is T {
  return value !== undefined && value !== null;
}

/**
 * Checks if value is defined (!== undefined, !== null).
 */
export function IsDefined(validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_DEFINED,
      validator: {
        validate: (value): boolean => isDefined(value),
        defaultMessage: buildMessage(
          eachPrefix => eachPrefix + '$property should not be null or undefined',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/common/IsEmpty.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';

export const IS_EMPTY = 'isEmpty';

/**
 * Checks if given value is empty (=== '', === null, === undefined).
 */
export function isEmpty(value: unknown): boolean {
  return value === '' || value === null || value === undefined;
}

/**
 * Checks if given value is empty (=== '', === null, === undefined).
 */
export function IsEmpty(validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_EMPTY,
      validator: {
        validate: (value, args): boolean => isEmpty(value),
        defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be empty', validationOptions),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/common/IsIn.spec.ts
================================================
import { isIn } from './IsIn';

describe('@IsIn decorator implementation', () => {
  describe('isIn validator', () => {
    it('should accept valid values', () => {
      expect(isIn('A', ['A', 'B'])).toBe(true);
      expect(isIn('A', ['B', 'C'])).toBe(false);
      expect(isIn('A', [1, 2])).toBe(false);
    });

    it('should not accept invalid values', () => {
      expect(isIn('A', 5 as any)).toBe(false);
      expect(isIn('A', 'ABC' as any)).toBe(false);
      expect(isIn('A', false as any)).toBe(false);
    });
  });
});


================================================
FILE: src/decorator/common/IsIn.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';

export const IS_IN = 'isIn';

/**
 * Checks if given value is in a array of allowed values.
 */
export function isIn(value: unknown, possibleValues: readonly unknown[]): boolean {
  return Array.isArray(possibleValues) && possibleValues.some(possibleValue => possibleValue === value);
}

/**
 * Checks if given value is in a array of allowed values.
 */
export function IsIn(values: readonly any[], validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_IN,
      constraints: [values],
      validator: {
        validate: (value, args): boolean => isIn(value, args?.constraints[0]),
        defaultMessage: buildMessage(
          eachPrefix => eachPrefix + '$property must be one of the following values: $constraint1',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/common/IsLatLong.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from './ValidateBy';
import isLatLongValidator from 'validator/lib/isLatLong';

export const IS_LATLONG = 'isLatLong';

/**
 * Checks if a value is string in format a "latitude,longitude".
 */
export function isLatLong(value: string): boolean {
  return typeof value === 'string' && isLatLongValidator(value);
}

/**
 * Checks if a value is string in format a "latitude,longitude".
 */
export function IsLatLong(validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_LATLONG,
      validator: {
        validate: (value, args): boolean => isLatLong(value),
        defaultMessage: buildMessage(
          eachPrefix => eachPrefix + '$property must be a latitude,longitude string',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/common/IsLatitude.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from './ValidateBy';
import { isLatLong } from './IsLatLong';

export const IS_LATITUDE = 'isLatitude';

/**
 * Checks if a given value is a latitude.
 */
export function isLatitude(value: string): boolean {
  return (typeof value === 'number' || typeof value === 'string') && isLatLong(`${value},0`);
}

/**
 * Checks if a given value is a latitude.
 */
export function IsLatitude(validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_LATITUDE,
      validator: {
        validate: (value, args): boolean => isLatitude(value),
        defaultMessage: buildMessage(
          eachPrefix => eachPrefix + '$property must be a latitude string or number',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/common/IsLongitude.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from './ValidateBy';
import { isLatLong } from './IsLatLong';

export const IS_LONGITUDE = 'isLongitude';

/**
 * Checks if a given value is a longitude.
 */
export function isLongitude(value: string): boolean {
  return (typeof value === 'number' || typeof value === 'string') && isLatLong(`0,${value}`);
}

/**
 * Checks if a given value is a longitude.
 */
export function IsLongitude(validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_LONGITUDE,
      validator: {
        validate: (value, args): boolean => isLongitude(value),
        defaultMessage: buildMessage(
          eachPrefix => eachPrefix + '$property must be a longitude string or number',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/common/IsNotEmpty.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';

export const IS_NOT_EMPTY = 'isNotEmpty';

/**
 * Checks if given value is not empty (!== '', !== null, !== undefined).
 */
export function isNotEmpty(value: unknown): boolean {
  return value !== '' && value !== null && value !== undefined;
}

/**
 * Checks if given value is not empty (!== '', !== null, !== undefined).
 */
export function IsNotEmpty(validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_NOT_EMPTY,
      validator: {
        validate: (value, args): boolean => isNotEmpty(value),
        defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property should not be empty', validationOptions),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/common/IsNotIn.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';

export const IS_NOT_IN = 'isNotIn';

/**
 * Checks if given value not in a array of allowed values.
 */
export function isNotIn(value: unknown, possibleValues: readonly unknown[]): boolean {
  return !Array.isArray(possibleValues) || !possibleValues.some(possibleValue => possibleValue === value);
}

/**
 * Checks if given value not in a array of allowed values.
 */
export function IsNotIn(values: readonly any[], validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_NOT_IN,
      constraints: [values],
      validator: {
        validate: (value, args): boolean => isNotIn(value, args?.constraints[0]),
        defaultMessage: buildMessage(
          eachPrefix => eachPrefix + '$property should not be one of the following values: $constraint1',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/common/IsOptional.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { ValidationMetadataArgs } from '../../metadata/ValidationMetadataArgs';
import { ValidationTypes } from '../../validation/ValidationTypes';
import { ValidationMetadata } from '../../metadata/ValidationMetadata';
import { getMetadataStorage } from '../../metadata/MetadataStorage';

export const IS_OPTIONAL = 'isOptional';

/**
 * Checks if value is missing and if so, ignores all validators.
 */
export function IsOptional(validationOptions?: ValidationOptions): PropertyDecorator {
  return function (object: object, propertyName: string): void {
    const args: ValidationMetadataArgs = {
      type: ValidationTypes.CONDITIONAL_VALIDATION,
      name: IS_OPTIONAL,
      target: object.constructor,
      propertyName: propertyName,
      constraints: [
        (object: any, value: any): boolean => {
          return object[propertyName] !== null && object[propertyName] !== undefined;
        },
      ],
      validationOptions: validationOptions,
    };
    getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
  };
}


================================================
FILE: src/decorator/common/NotEquals.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';

export const NOT_EQUALS = 'notEquals';

/**
 * Checks if value does not match ("!==") the comparison.
 */
export function notEquals(value: unknown, comparison: unknown): boolean {
  return value !== comparison;
}

/**
 * Checks if value does not match ("!==") the comparison.
 */
export function NotEquals(comparison: any, validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: NOT_EQUALS,
      constraints: [comparison],
      validator: {
        validate: (value, args): boolean => notEquals(value, args?.constraints[0]),
        defaultMessage: buildMessage(
          eachPrefix => eachPrefix + '$property should not be equal to $constraint1',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/common/Validate.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { ValidationMetadataArgs } from '../../metadata/ValidationMetadataArgs';
import { ValidationMetadata } from '../../metadata/ValidationMetadata';
import { getMetadataStorage } from '../../metadata/MetadataStorage';
import { ValidationTypes } from '../../validation/ValidationTypes';
import { ConstraintMetadata } from '../../metadata/ConstraintMetadata';

/**
 * Registers custom validator class.
 */
export function ValidatorConstraint(options?: { name?: string; async?: boolean }) {
  return function (target: Function): void {
    const isAsync = options && options.async;
    let name = options && options.name ? options.name : '';
    if (!name) {
      name = (target as any).name;
      if (!name)
        // generate name if it was not given
        name = name.replace(/\.?([A-Z]+)/g, (x, y) => '_' + (y as string).toLowerCase()).replace(/^_/, '');
    }
    const metadata = new ConstraintMetadata(target, name, isAsync);
    getMetadataStorage().addConstraintMetadata(metadata);
  };
}

/**
 * Performs validation based on the given custom validation class.
 * Validation class must be decorated with ValidatorConstraint decorator.
 */
export function Validate(constraintClass: Function, validationOptions?: ValidationOptions): PropertyDecorator;
export function Validate(
  constraintClass: Function,
  constraints?: any[],
  validationOptions?: ValidationOptions
): PropertyDecorator;
export function Validate(
  constraintClass: Function,
  constraintsOrValidationOptions?: any[] | ValidationOptions,
  maybeValidationOptions?: ValidationOptions
): PropertyDecorator {
  return function (object: object, propertyName: string): void {
    const args: ValidationMetadataArgs = {
      type: ValidationTypes.CUSTOM_VALIDATION,
      target: object.constructor,
      propertyName: propertyName,
      constraintCls: constraintClass,
      constraints: Array.isArray(constraintsOrValidationOptions) ? constraintsOrValidationOptions : undefined,
      validationOptions: !Array.isArray(constraintsOrValidationOptions)
        ? constraintsOrValidationOptions
        : maybeValidationOptions,
    };
    getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
  };
}


================================================
FILE: src/decorator/common/ValidateBy.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { registerDecorator } from '../../register-decorator';
import { ValidationArguments } from '../../validation/ValidationArguments';
import { ValidatorConstraintInterface } from '../../validation/ValidatorConstraintInterface';

export interface ValidateByOptions {
  name: string;
  constraints?: any[];
  validator: ValidatorConstraintInterface | Function;
  async?: boolean;
}

export function buildMessage(
  impl: (eachPrefix: string, args?: ValidationArguments) => string,
  validationOptions?: ValidationOptions
): (validationArguments?: ValidationArguments) => string {
  return (validationArguments?: ValidationArguments): string => {
    const eachPrefix = validationOptions && validationOptions.each ? 'each value in ' : '';
    return impl(eachPrefix, validationArguments);
  };
}

export function ValidateBy(options: ValidateByOptions, validationOptions?: ValidationOptions): PropertyDecorator {
  return function (object: object, propertyName: string): void {
    registerDecorator({
      name: options.name,
      target: object.constructor,
      propertyName: propertyName,
      options: validationOptions,
      constraints: options.constraints,
      validator: options.validator,
    });
  };
}


================================================
FILE: src/decorator/common/ValidateIf.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { ValidationMetadataArgs } from '../../metadata/ValidationMetadataArgs';
import { ValidationTypes } from '../../validation/ValidationTypes';
import { ValidationMetadata } from '../../metadata/ValidationMetadata';
import { getMetadataStorage } from '../../metadata/MetadataStorage';

/**
 * Ignores the other validators on a property when the provided condition function returns false.
 */
export function ValidateIf(
  condition: (object: any, value: any) => boolean,
  validationOptions?: ValidationOptions
): PropertyDecorator {
  return function (object: object, propertyName: string): void {
    const args: ValidationMetadataArgs = {
      type: ValidationTypes.CONDITIONAL_VALIDATION,
      target: object.constructor,
      propertyName: propertyName,
      constraints: [condition],
      validationOptions: validationOptions,
    };
    getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
  };
}


================================================
FILE: src/decorator/common/ValidateNested.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { ValidationMetadataArgs } from '../../metadata/ValidationMetadataArgs';
import { ValidationTypes } from '../../validation/ValidationTypes';
import { ValidationMetadata } from '../../metadata/ValidationMetadata';
import { getMetadataStorage } from '../../metadata/MetadataStorage';

/**
 * Objects / object arrays marked with this decorator will also be validated.
 */
export function ValidateNested(validationOptions?: ValidationOptions): PropertyDecorator {
  const opts: ValidationOptions = { ...validationOptions };
  const eachPrefix = opts.each ? 'each value in ' : '';
  opts.message = opts.message || eachPrefix + 'nested property $property must be either object or array';

  return function (object: object, propertyName: string): void {
    const args: ValidationMetadataArgs = {
      type: ValidationTypes.NESTED_VALIDATION,
      target: object.constructor,
      propertyName: propertyName,
      validationOptions: opts,
    };
    getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
  };
}


================================================
FILE: src/decorator/common/ValidatePromise.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { ValidationMetadataArgs } from '../../metadata/ValidationMetadataArgs';
import { ValidationTypes } from '../../validation/ValidationTypes';
import { ValidationMetadata } from '../../metadata/ValidationMetadata';
import { getMetadataStorage } from '../../metadata/MetadataStorage';

/**
 * Resolve promise before validation
 */
export function ValidatePromise(validationOptions?: ValidationOptions): PropertyDecorator {
  return function (object: object, propertyName: string): void {
    const args: ValidationMetadataArgs = {
      type: ValidationTypes.PROMISE_VALIDATION,
      target: object.constructor,
      propertyName: propertyName,
      validationOptions: validationOptions,
    };
    getMetadataStorage().addValidationMetadata(new ValidationMetadata(args));
  };
}


================================================
FILE: src/decorator/date/MaxDate.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';

export const MAX_DATE = 'maxDate';

/**
 * Checks if the value is a date that's before the specified date.
 */
export function maxDate(date: unknown, maxDate: Date | (() => Date)): boolean {
  return date instanceof Date && date.getTime() <= (maxDate instanceof Date ? maxDate : maxDate()).getTime();
}

/**
 * Checks if the value is a date that's before the specified date.
 */
export function MaxDate(date: Date | (() => Date), validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: MAX_DATE,
      constraints: [date],
      validator: {
        validate: (value, args): boolean => maxDate(value, args?.constraints[0]),
        defaultMessage: buildMessage(
          eachPrefix => 'maximal allowed date for ' + eachPrefix + '$property is $constraint1',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/date/MinDate.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';

export const MIN_DATE = 'minDate';

/**
 * Checks if the value is a date that's after the specified date.
 */
export function minDate(date: unknown, minDate: Date | (() => Date)): boolean {
  return date instanceof Date && date.getTime() >= (minDate instanceof Date ? minDate : minDate()).getTime();
}

/**
 * Checks if the value is a date that's after the specified date.
 */
export function MinDate(date: Date | (() => Date), validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: MIN_DATE,
      constraints: [date],
      validator: {
        validate: (value, args): boolean => minDate(value, args?.constraints[0]),
        defaultMessage: buildMessage(
          eachPrefix => 'minimal allowed date for ' + eachPrefix + '$property is $constraint1',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/decorators.ts
================================================
// -------------------------------------------------------------------------
// System
// -------------------------------------------------------------------------

// -------------------------------------------------------------------------
// Common checkers
// -------------------------------------------------------------------------

export * from './common/Allow';
export * from './common/IsDefined';
export * from './common/IsOptional';
export * from './common/Validate';
export * from './common/ValidateBy';
export * from './common/ValidateIf';
export * from './common/ValidateNested';
export * from './common/ValidatePromise';
export * from './common/IsLatLong';
export * from './common/IsLatitude';
export * from './common/IsLongitude';
export * from './common/Equals';
export * from './common/NotEquals';
export * from './common/IsEmpty';
export * from './common/IsNotEmpty';
export * from './common/IsIn';
export * from './common/IsNotIn';

// -------------------------------------------------------------------------
// Number checkers
// -------------------------------------------------------------------------

export * from './number/IsDivisibleBy';
export * from './number/IsPositive';
export * from './number/IsNegative';
export * from './number/Max';
export * from './number/Min';

// -------------------------------------------------------------------------
// Date checkers
// -------------------------------------------------------------------------

export * from './date/MinDate';
export * from './date/MaxDate';

// -------------------------------------------------------------------------
// String checkers
// -------------------------------------------------------------------------

export * from './string/Contains';
export * from './string/NotContains';
export * from './string/IsAlpha';
export * from './string/IsAlphanumeric';
export * from './string/IsDecimal';
export * from './string/IsAscii';
export * from './string/IsBase64';
export * from './string/IsByteLength';
export * from './string/IsCreditCard';
export * from './string/IsCurrency';
export * from './string/IsEmail';
export * from './string/IsFQDN';
export * from './string/IsFullWidth';
export * from './string/IsHalfWidth';
export * from './string/IsVariableWidth';
export * from './string/IsHexColor';
export * from './string/IsHexadecimal';
export * from './string/IsMacAddress';
export * from './string/IsIP';
export * from './string/IsPort';
export * from './string/IsISBN';
export * from './string/IsISIN';
export * from './string/IsISO8601';
export * from './string/IsJSON';
export * from './string/IsJWT';
export * from './string/IsLowercase';
export * from './string/IsMobilePhone';
export * from './string/IsISO31661Alpha2';
export * from './string/IsISO31661Alpha3';
export * from './string/IsISO31661Numeric';
export * from './string/IsMongoId';
export * from './string/IsMultibyte';
export * from './string/IsSurrogatePair';
export * from './string/IsUrl';
export * from './string/IsUUID';
export * from './string/IsFirebasePushId';
export * from './string/IsUppercase';
export * from './string/Length';
export * from './string/MaxLength';
export * from './string/MinLength';
export * from './string/Matches';
export * from './string/IsPhoneNumber';
export * from './string/IsMilitaryTime';
export * from './string/IsHash';
export * from './string/IsISSN';
export * from './string/IsDateString';
export * from './string/IsBooleanString';
export * from './string/IsNumberString';
export * from './string/IsBase32';
export * from './string/IsBIC';
export * from './string/IsBtcAddress';
export * from './string/IsDataURI';
export * from './string/IsEAN';
export * from './string/IsEthereumAddress';
export * from './string/IsHSL';
export * from './string/IsIBAN';
export * from './string/IsIdentityCard';
export * from './string/IsISRC';
export * from './string/IsLocale';
export * from './string/IsMagnetURI';
export * from './string/IsMimeType';
export * from './string/IsOctal';
export * from './string/IsPassportNumber';
export * from './string/IsPostalCode';
export * from './string/IsRFC3339';
export * from './string/IsRgbColor';
export * from './string/IsSemVer';
export * from './string/IsStrongPassword';
export * from './string/IsTimeZone';
export * from './string/IsBase58';
export * from './string/is-tax-id';
export * from './string/is-iso4217-currency-code';
export * from './string/isISO6391';

// -------------------------------------------------------------------------
// Type checkers
// -------------------------------------------------------------------------

export * from './typechecker/IsBoolean';
export * from './typechecker/IsDate';
export * from './typechecker/IsNumber';
export * from './typechecker/IsEnum';
export * from './typechecker/IsInt';
export * from './typechecker/IsString';
export * from './typechecker/IsArray';
export * from './typechecker/IsObject';

// -------------------------------------------------------------------------
// Array checkers
// -------------------------------------------------------------------------

export * from './array/ArrayContains';
export * from './array/ArrayNotContains';
export * from './array/ArrayNotEmpty';
export * from './array/ArrayMinSize';
export * from './array/ArrayMaxSize';
export * from './array/ArrayUnique';

// -------------------------------------------------------------------------
// Object checkers
// -------------------------------------------------------------------------

export * from './object/IsNotEmptyObject';
export * from './object/IsInstance';


================================================
FILE: src/decorator/number/IsDivisibleBy.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isDivisibleByValidator from 'validator/lib/isDivisibleBy';

export const IS_DIVISIBLE_BY = 'isDivisibleBy';

/**
 * Checks if value is a number that's divisible by another.
 */
export function isDivisibleBy(value: unknown, num: number): boolean {
  return typeof value === 'number' && typeof num === 'number' && isDivisibleByValidator(String(value), num);
}

/**
 * Checks if value is a number that's divisible by another.
 */
export function IsDivisibleBy(num: number, validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_DIVISIBLE_BY,
      constraints: [num],
      validator: {
        validate: (value, args): boolean => isDivisibleBy(value, args?.constraints[0]),
        defaultMessage: buildMessage(
          eachPrefix => eachPrefix + '$property must be divisible by $constraint1',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/number/IsNegative.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';

export const IS_NEGATIVE = 'isNegative';

/**
 * Checks if the value is a negative number smaller than zero.
 */
export function isNegative(value: unknown): boolean {
  return typeof value === 'number' && value < 0;
}

/**
 * Checks if the value is a negative number smaller than zero.
 */
export function IsNegative(validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_NEGATIVE,
      validator: {
        validate: (value, args): boolean => isNegative(value),
        defaultMessage: buildMessage(
          eachPrefix => eachPrefix + '$property must be a negative number',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/number/IsPositive.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';

export const IS_POSITIVE = 'isPositive';

/**
 * Checks if the value is a positive number greater than zero.
 */
export function isPositive(value: unknown): boolean {
  return typeof value === 'number' && value > 0;
}

/**
 * Checks if the value is a positive number greater than zero.
 */
export function IsPositive(validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_POSITIVE,
      validator: {
        validate: (value, args): boolean => isPositive(value),
        defaultMessage: buildMessage(
          eachPrefix => eachPrefix + '$property must be a positive number',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/number/Max.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';

export const MAX = 'max';

/**
 * Checks if the first number is less than or equal to the second.
 */
export function max(num: unknown, max: number): boolean {
  return typeof num === 'number' && typeof max === 'number' && num <= max;
}

/**
 * Checks if the value is less than or equal to the allowed maximum value.
 */
export function Max(maxValue: number, validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: MAX,
      constraints: [maxValue],
      validator: {
        validate: (value, args): boolean => max(value, args?.constraints[0]),
        defaultMessage: buildMessage(
          eachPrefix => eachPrefix + '$property must not be greater than $constraint1',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/number/Min.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';

export const MIN = 'min';

/**
 * Checks if the first number is greater than or equal to the second.
 */
export function min(num: unknown, min: number): boolean {
  return typeof num === 'number' && typeof min === 'number' && num >= min;
}

/**
 * Checks if the value is greater than or equal to the allowed minimum value.
 */
export function Min(minValue: number, validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: MIN,
      constraints: [minValue],
      validator: {
        validate: (value, args): boolean => min(value, args?.constraints[0]),
        defaultMessage: buildMessage(
          eachPrefix => eachPrefix + '$property must not be less than $constraint1',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/object/IsInstance.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';

export const IS_INSTANCE = 'isInstance';

/**
 * Checks if the value is an instance of the specified object.
 */
export function isInstance(object: unknown, targetTypeConstructor: new (...args: any[]) => any): boolean {
  return (
    targetTypeConstructor && typeof targetTypeConstructor === 'function' && object instanceof targetTypeConstructor
  );
}

/**
 * Checks if the value is an instance of the specified object.
 */
export function IsInstance(
  targetType: new (...args: any[]) => any,
  validationOptions?: ValidationOptions
): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_INSTANCE,
      constraints: [targetType],
      validator: {
        validate: (value, args): boolean => isInstance(value, args?.constraints[0]),
        defaultMessage: buildMessage((eachPrefix, args) => {
          if (args?.constraints[0]) {
            return eachPrefix + `$property must be an instance of ${args?.constraints[0].name as string}`;
          } else {
            return eachPrefix + `${IS_INSTANCE} decorator expects and object as value, but got falsy value.`;
          }
        }, validationOptions),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/object/IsNotEmptyObject.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import { isObject } from '../typechecker/IsObject';

export const IS_NOT_EMPTY_OBJECT = 'isNotEmptyObject';

/**
 * Checks if the value is valid Object & not empty.
 * Returns false if the value is not an object or an empty valid object.
 */
export function isNotEmptyObject(value: unknown, options?: { nullable?: boolean }): boolean {
  if (!isObject(value)) {
    return false;
  }

  if (options?.nullable === false) {
    return !Object.values(value).every(propertyValue => propertyValue === null || propertyValue === undefined);
  }

  for (const key in value) {
    if (value.hasOwnProperty(key)) {
      return true;
    }
  }

  return false;
}

/**
 * Checks if the value is valid Object & not empty.
 * Returns false if the value is not an object or an empty valid object.
 */
export function IsNotEmptyObject(
  options?: { nullable?: boolean },
  validationOptions?: ValidationOptions
): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_NOT_EMPTY_OBJECT,
      constraints: [options],
      validator: {
        validate: (value, args): boolean => isNotEmptyObject(value, args?.constraints[0]),
        defaultMessage: buildMessage(
          eachPrefix => eachPrefix + '$property must be a non-empty object',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/string/Contains.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import containsValidator from 'validator/lib/contains';

export const CONTAINS = 'contains';

/**
 * Checks if the string contains the seed.
 * If given value is not a string, then it returns false.
 */
export function contains(value: unknown, seed: string): boolean {
  return typeof value === 'string' && containsValidator(value, seed);
}

/**
 * Checks if the string contains the seed.
 * If given value is not a string, then it returns false.
 */
export function Contains(seed: string, validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: CONTAINS,
      constraints: [seed],
      validator: {
        validate: (value, args): boolean => contains(value, args?.constraints[0]),
        defaultMessage: buildMessage(
          eachPrefix => eachPrefix + '$property must contain a $constraint1 string',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/string/IsAlpha.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isAlphaValidator from 'validator/lib/isAlpha';
import * as ValidatorJS from 'validator';

export const IS_ALPHA = 'isAlpha';

/**
 * Checks if the string contains only letters (a-zA-Z).
 * If given value is not a string, then it returns false.
 */
export function isAlpha(value: unknown, locale?: ValidatorJS.AlphaLocale): boolean {
  return typeof value === 'string' && isAlphaValidator(value, locale);
}

/**
 * Checks if the string contains only letters (a-zA-Z).
 * If given value is not a string, then it returns false.
 */
export function IsAlpha(locale?: ValidatorJS.AlphaLocale, validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_ALPHA,
      constraints: [locale],
      validator: {
        validate: (value, args): boolean => isAlpha(value, args?.constraints[0]),
        defaultMessage: buildMessage(
          eachPrefix => eachPrefix + '$property must contain only letters (a-zA-Z)',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/string/IsAlphanumeric.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isAlphanumericValidator from 'validator/lib/isAlphanumeric';
import * as ValidatorJS from 'validator';

export const IS_ALPHANUMERIC = 'isAlphanumeric';

/**
 * Checks if the string contains only letters and numbers.
 * If given value is not a string, then it returns false.
 */
export function isAlphanumeric(value: unknown, locale?: ValidatorJS.AlphanumericLocale): boolean {
  return typeof value === 'string' && isAlphanumericValidator(value, locale);
}

/**
 * Checks if the string contains only letters and numbers.
 * If given value is not a string, then it returns false.
 */
export function IsAlphanumeric(
  locale?: ValidatorJS.AlphanumericLocale,
  validationOptions?: ValidationOptions
): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_ALPHANUMERIC,
      constraints: [locale],
      validator: {
        validate: (value, args): boolean => isAlphanumeric(value, args?.constraints[0]),
        defaultMessage: buildMessage(
          eachPrefix => eachPrefix + '$property must contain only letters and numbers',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/string/IsAscii.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isAsciiValidator from 'validator/lib/isAscii';

export const IS_ASCII = 'isAscii';

/**
 * Checks if the string contains ASCII chars only.
 * If given value is not a string, then it returns false.
 */
export function isAscii(value: unknown): boolean {
  return typeof value === 'string' && isAsciiValidator(value);
}

/**
 * Checks if the string contains ASCII chars only.
 * If given value is not a string, then it returns false.
 */
export function IsAscii(validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_ASCII,
      validator: {
        validate: (value, args): boolean => isAscii(value),
        defaultMessage: buildMessage(
          eachPrefix => eachPrefix + '$property must contain only ASCII characters',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/string/IsBIC.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isBICValidator from 'validator/lib/isBIC';

export const IS_BIC = '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.
 */
export function isBIC(value: unknown): boolean {
  return typeof value === 'string' && isBICValidator(value);
}

/**
 * Check if a string is a BIC (Bank Identification Code) or SWIFT code.
 * If given value is not a string, then it returns false.
 */
export function IsBIC(validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_BIC,
      validator: {
        validate: (value, args): boolean => isBIC(value),
        defaultMessage: buildMessage(
          eachPrefix => eachPrefix + '$property must be a BIC or SWIFT code',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/string/IsBase32.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isBase32Validator from 'validator/lib/isBase32';

export const IS_BASE32 = 'isBase32';

/**
 * Checks if a string is base32 encoded.
 * If given value is not a string, then it returns false.
 */
export function isBase32(value: unknown): boolean {
  return typeof value === 'string' && isBase32Validator(value);
}

/**
 * Check if a string is base32 encoded.
 * If given value is not a string, then it returns false.
 */
export function IsBase32(validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_BASE32,
      validator: {
        validate: (value, args): boolean => isBase32(value),
        defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be base32 encoded', validationOptions),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/string/IsBase58.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isBase58Validator from 'validator/lib/isBase58';

export const IS_BASE58 = 'isBase58';

/**
 * Checks if a string is base58 encoded.
 * If given value is not a string, then it returns false.
 */
export function isBase58(value: unknown): boolean {
  return typeof value === 'string' && isBase58Validator(value);
}

/**
 * Checks if a string is base58 encoded.
 * If given value is not a string, then it returns false.
 */
export function IsBase58(validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_BASE58,
      validator: {
        validate: (value, args): boolean => isBase58(value),
        defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be base58 encoded', validationOptions),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/string/IsBase64.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isBase64Validator from 'validator/lib/isBase64';
import * as ValidatorJS from 'validator';

export const IS_BASE64 = 'isBase64';

/**
 * Checks if a string is base64 encoded.
 * If given value is not a string, then it returns false.
 */
export function isBase64(value: unknown, options?: ValidatorJS.IsBase64Options): boolean {
  return typeof value === 'string' && isBase64Validator(value, options);
}

/**
 * Checks if a string is base64 encoded.
 * If given value is not a string, then it returns false.
 */
export function IsBase64(
  options?: ValidatorJS.IsBase64Options,
  validationOptions?: ValidationOptions
): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_BASE64,
      constraints: [options],
      validator: {
        validate: (value, args): boolean => isBase64(value, args?.constraints[0]),
        defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be base64 encoded', validationOptions),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/string/IsBooleanString.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isBooleanValidator from 'validator/lib/isBoolean';

export const IS_BOOLEAN_STRING = 'isBooleanString';

/**
 * Checks if a string is a boolean.
 * If given value is not a string, then it returns false.
 */
export function isBooleanString(value: unknown): boolean {
  return typeof value === 'string' && isBooleanValidator(value);
}

/**
 * Checks if a string is a boolean.
 * If given value is not a string, then it returns false.
 */
export function IsBooleanString(validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_BOOLEAN_STRING,
      validator: {
        validate: (value, args): boolean => isBooleanString(value),
        defaultMessage: buildMessage(
          eachPrefix => eachPrefix + '$property must be a boolean string',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/string/IsBtcAddress.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isBtcAddressValidator from 'validator/lib/isBtcAddress';

export const IS_BTC_ADDRESS = 'isBtcAddress';

/**
 * Check if the string is a valid BTC address.
 * If given value is not a string, then it returns false.
 */
export function isBtcAddress(value: unknown): boolean {
  return typeof value === 'string' && isBtcAddressValidator(value);
}

/**
 * Check if the string is a valid BTC address.
 * If given value is not a string, then it returns false.
 */
export function IsBtcAddress(validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_BTC_ADDRESS,
      validator: {
        validate: (value, args): boolean => isBtcAddress(value),
        defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be a BTC address', validationOptions),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/string/IsByteLength.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isByteLengthValidator from 'validator/lib/isByteLength';

export const IS_BYTE_LENGTH = 'isByteLength';

/**
 * Checks if the string's length (in bytes) falls in a range.
 * If given value is not a string, then it returns false.
 */
export function isByteLength(value: unknown, min: number, max?: number): boolean {
  return typeof value === 'string' && isByteLengthValidator(value, { min, max });
}

/**
 * Checks if the string's length (in bytes) falls in a range.
 * If given value is not a string, then it returns false.
 */
export function IsByteLength(min: number, max?: number, validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_BYTE_LENGTH,
      constraints: [min, max],
      validator: {
        validate: (value, args): boolean => isByteLength(value, args?.constraints[0], args?.constraints[1]),
        defaultMessage: buildMessage(
          eachPrefix => eachPrefix + "$property's byte length must fall into ($constraint1, $constraint2) range",
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/string/IsCreditCard.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isCreditCardValidator from 'validator/lib/isCreditCard';

export const IS_CREDIT_CARD = 'isCreditCard';

/**
 * Checks if the string is a credit card.
 * If given value is not a string, then it returns false.
 */
export function isCreditCard(value: unknown): boolean {
  return typeof value === 'string' && isCreditCardValidator(value);
}

/**
 * Checks if the string is a credit card.
 * If given value is not a string, then it returns false.
 */
export function IsCreditCard(validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_CREDIT_CARD,
      validator: {
        validate: (value, args): boolean => isCreditCard(value),
        defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be a credit card', validationOptions),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/string/IsCurrency.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isCurrencyValidator from 'validator/lib/isCurrency';
import * as ValidatorJS from 'validator';

export const IS_CURRENCY = 'isCurrency';

/**
 * Checks if the string is a valid currency amount.
 * If given value is not a string, then it returns false.
 */
export function isCurrency(value: unknown, options?: ValidatorJS.IsCurrencyOptions): boolean {
  return typeof value === 'string' && isCurrencyValidator(value, options);
}

/**
 * Checks if the string is a valid currency amount.
 * If given value is not a string, then it returns false.
 */
export function IsCurrency(
  options?: ValidatorJS.IsCurrencyOptions,
  validationOptions?: ValidationOptions
): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_CURRENCY,
      constraints: [options],
      validator: {
        validate: (value, args): boolean => isCurrency(value, args?.constraints[0]),
        defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be a currency', validationOptions),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/string/IsDataURI.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isDataURIValidator from 'validator/lib/isDataURI';

export const IS_DATA_URI = 'isDataURI';

/**
 * Check if the string is a data uri format.
 * If given value is not a string, then it returns false.
 */
export function isDataURI(value: unknown): boolean {
  return typeof value === 'string' && isDataURIValidator(value);
}

/**
 * Check if the string is a data uri format.
 * If given value is not a string, then it returns false.
 */
export function IsDataURI(validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_DATA_URI,
      validator: {
        validate: (value, args): boolean => isDataURI(value),
        defaultMessage: buildMessage(
          eachPrefix => eachPrefix + '$property must be a data uri format',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/string/IsDateString.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import * as ValidatorJS from 'validator';
import { isISO8601 } from './IsISO8601';

export const IS_DATE_STRING = 'isDateString';

/**
 * Alias for IsISO8601 validator
 */
export function isDateString(value: unknown, options?: ValidatorJS.IsISO8601Options): boolean {
  return isISO8601(value, options);
}

/**
 * Alias for IsISO8601 validator
 */
export function IsDateString(
  options?: ValidatorJS.IsISO8601Options,
  validationOptions?: ValidationOptions
): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_DATE_STRING,
      constraints: [options],
      validator: {
        validate: (value): boolean => isDateString(value, options),
        defaultMessage: buildMessage(
          eachPrefix => eachPrefix + '$property must be a valid ISO 8601 date string',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/string/IsDecimal.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isDecimalValidator from 'validator/lib/isDecimal';
import * as ValidatorJS from 'validator';

export const IS_DECIMAL = 'isDecimal';

/**
 * Checks if the string is a valid decimal.
 * If given value is not a string, then it returns false.
 */
export function isDecimal(value: unknown, options?: ValidatorJS.IsDecimalOptions): boolean {
  return typeof value === 'string' && isDecimalValidator(value, options);
}

/**
 * Checks if the string is a valid decimal.
 * If given value is not a string, then it returns false.
 */
export function IsDecimal(
  options?: ValidatorJS.IsDecimalOptions,
  validationOptions?: ValidationOptions
): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_DECIMAL,
      constraints: [options],
      validator: {
        validate: (value, args): boolean => isDecimal(value, args?.constraints[0]),
        defaultMessage: buildMessage(
          eachPrefix => eachPrefix + '$property is not a valid decimal number.',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/string/IsEAN.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isEANValidator from 'validator/lib/isEAN';

export const IS_EAN = 'isEAN';

/**
 * Check if the string is an EAN (European Article Number).
 * If given value is not a string, then it returns false.
 */
export function isEAN(value: unknown): boolean {
  return typeof value === 'string' && isEANValidator(value);
}

/**
 * Check if the string is an EAN (European Article Number).
 * If given value is not a string, then it returns false.
 */
export function IsEAN(validationOptions?: ValidationOptions): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_EAN,
      validator: {
        validate: (value, args): boolean => isEAN(value),
        defaultMessage: buildMessage(
          eachPrefix => eachPrefix + '$property must be an EAN (European Article Number)',
          validationOptions
        ),
      },
    },
    validationOptions
  );
}


================================================
FILE: src/decorator/string/IsEmail.ts
================================================
import { ValidationOptions } from '../ValidationOptions';
import { buildMessage, ValidateBy } from '../common/ValidateBy';
import isEmailValidator from 'validator/lib/isEmail';
import * as ValidatorJS from 'validator';

export const IS_EMAIL = 'isEmail';

/**
 * Checks if the string is an email.
 * If given value is not a string, then it returns false.
 */
export function isEmail(value: unknown, options?: ValidatorJS.IsEmailOptions): boolean {
  return typeof value === 'string' && isEmailValidator(value, options);
}

/**
 * Checks if the string is an email.
 * If given value is not a string, then it returns false.
 */
export function IsEmail(
  options?: ValidatorJS.IsEmailOptions,
  validationOptions?: ValidationOptions
): PropertyDecorator {
  return ValidateBy(
    {
      name: IS_EMAIL,
      constraints: [options],
      validator: {
        validate: (value, args): boolean => isEmail(value, args?.constraints[0]),
        defaultMessage: buildMessage(eachPrefix => eachPrefix + '$property must be an email', validationOptions),
      },
    },
    v
Download .txt
gitextract_sok6jg66/

├── .eslintrc.yml
├── .gitbook.yaml
├── .github/
│   ├── dependabot.yml
│   ├── semantic.yml
│   └── workflows/
│       ├── auto-approve-dependabot-workflow.yml
│       ├── continuous-deployment-workflow.yml
│       ├── continuous-integration-workflow.yml
│       └── lock-closed-issues-workflow.yml
├── .gitignore
├── .prettierrc.yml
├── CHANGELOG.md
├── LICENSE
├── README.md
├── codecov.yml
├── docs/
│   ├── README.md
│   ├── basics/
│   │   └── validating-objects.md
│   └── introduction/
│       └── installation.md
├── jest.config.js
├── package.json
├── rollup.config.js
├── sample/
│   ├── sample1-simple-validation/
│   │   ├── Post.ts
│   │   └── app.ts
│   ├── sample2-using-groups/
│   │   ├── Post.ts
│   │   └── app.ts
│   ├── sample3-nested-objects/
│   │   ├── Post.ts
│   │   ├── Tag.ts
│   │   └── app.ts
│   ├── sample4-custom-validator/
│   │   ├── CustomTextLength.ts
│   │   ├── Post.ts
│   │   └── app.ts
│   ├── sample5-schemas/
│   │   ├── Post.ts
│   │   ├── app.ts
│   │   └── post.json
│   ├── sample6-custom-decorator/
│   │   ├── IsLongerThan.ts
│   │   ├── IsUserAlreadyExist.ts
│   │   ├── User.ts
│   │   └── app.ts
│   ├── sample7-inheritance-support/
│   │   ├── BaseContent.ts
│   │   ├── Post.ts
│   │   └── app.ts
│   ├── sample8-es6-maps/
│   │   ├── Post.ts
│   │   ├── Tag.ts
│   │   └── app.ts
│   └── sample9-es6-sets/
│       ├── Post.ts
│       ├── Tag.ts
│       └── app.ts
├── src/
│   ├── container.ts
│   ├── decorator/
│   │   ├── ValidationOptions.ts
│   │   ├── array/
│   │   │   ├── ArrayContains.ts
│   │   │   ├── ArrayMaxSize.ts
│   │   │   ├── ArrayMinSize.ts
│   │   │   ├── ArrayNotContains.ts
│   │   │   ├── ArrayNotEmpty.ts
│   │   │   └── ArrayUnique.ts
│   │   ├── common/
│   │   │   ├── Allow.ts
│   │   │   ├── Equals.ts
│   │   │   ├── IsDefined.ts
│   │   │   ├── IsEmpty.ts
│   │   │   ├── IsIn.spec.ts
│   │   │   ├── IsIn.ts
│   │   │   ├── IsLatLong.ts
│   │   │   ├── IsLatitude.ts
│   │   │   ├── IsLongitude.ts
│   │   │   ├── IsNotEmpty.ts
│   │   │   ├── IsNotIn.ts
│   │   │   ├── IsOptional.ts
│   │   │   ├── NotEquals.ts
│   │   │   ├── Validate.ts
│   │   │   ├── ValidateBy.ts
│   │   │   ├── ValidateIf.ts
│   │   │   ├── ValidateNested.ts
│   │   │   └── ValidatePromise.ts
│   │   ├── date/
│   │   │   ├── MaxDate.ts
│   │   │   └── MinDate.ts
│   │   ├── decorators.ts
│   │   ├── number/
│   │   │   ├── IsDivisibleBy.ts
│   │   │   ├── IsNegative.ts
│   │   │   ├── IsPositive.ts
│   │   │   ├── Max.ts
│   │   │   └── Min.ts
│   │   ├── object/
│   │   │   ├── IsInstance.ts
│   │   │   └── IsNotEmptyObject.ts
│   │   ├── string/
│   │   │   ├── Contains.ts
│   │   │   ├── IsAlpha.ts
│   │   │   ├── IsAlphanumeric.ts
│   │   │   ├── IsAscii.ts
│   │   │   ├── IsBIC.ts
│   │   │   ├── IsBase32.ts
│   │   │   ├── IsBase58.ts
│   │   │   ├── IsBase64.ts
│   │   │   ├── IsBooleanString.ts
│   │   │   ├── IsBtcAddress.ts
│   │   │   ├── IsByteLength.ts
│   │   │   ├── IsCreditCard.ts
│   │   │   ├── IsCurrency.ts
│   │   │   ├── IsDataURI.ts
│   │   │   ├── IsDateString.ts
│   │   │   ├── IsDecimal.ts
│   │   │   ├── IsEAN.ts
│   │   │   ├── IsEmail.ts
│   │   │   ├── IsEthereumAddress.ts
│   │   │   ├── IsFQDN.ts
│   │   │   ├── IsFirebasePushId.ts
│   │   │   ├── IsFullWidth.ts
│   │   │   ├── IsHSL.ts
│   │   │   ├── IsHalfWidth.ts
│   │   │   ├── IsHash.ts
│   │   │   ├── IsHexColor.ts
│   │   │   ├── IsHexadecimal.ts
│   │   │   ├── IsIBAN.ts
│   │   │   ├── IsIP.ts
│   │   │   ├── IsISBN.ts
│   │   │   ├── IsISIN.ts
│   │   │   ├── IsISO31661Alpha2.ts
│   │   │   ├── IsISO31661Alpha3.ts
│   │   │   ├── IsISO31661Numeric.ts
│   │   │   ├── IsISO8601.ts
│   │   │   ├── IsISRC.ts
│   │   │   ├── IsISSN.ts
│   │   │   ├── IsIdentityCard.ts
│   │   │   ├── IsJSON.ts
│   │   │   ├── IsJWT.ts
│   │   │   ├── IsLocale.ts
│   │   │   ├── IsLowercase.ts
│   │   │   ├── IsMacAddress.ts
│   │   │   ├── IsMagnetURI.ts
│   │   │   ├── IsMilitaryTime.ts
│   │   │   ├── IsMimeType.ts
│   │   │   ├── IsMobilePhone.ts
│   │   │   ├── IsMongoId.ts
│   │   │   ├── IsMultibyte.ts
│   │   │   ├── IsNumberString.ts
│   │   │   ├── IsOctal.ts
│   │   │   ├── IsPassportNumber.ts
│   │   │   ├── IsPhoneNumber.spec.ts
│   │   │   ├── IsPhoneNumber.ts
│   │   │   ├── IsPort.ts
│   │   │   ├── IsPostalCode.ts
│   │   │   ├── IsRFC3339.ts
│   │   │   ├── IsRgbColor.ts
│   │   │   ├── IsSemVer.ts
│   │   │   ├── IsStrongPassword.ts
│   │   │   ├── IsSurrogatePair.ts
│   │   │   ├── IsTimeZone.ts
│   │   │   ├── IsUUID.ts
│   │   │   ├── IsUppercase.ts
│   │   │   ├── IsUrl.ts
│   │   │   ├── IsVariableWidth.ts
│   │   │   ├── Length.ts
│   │   │   ├── Matches.ts
│   │   │   ├── MaxLength.ts
│   │   │   ├── MinLength.ts
│   │   │   ├── NotContains.ts
│   │   │   ├── is-iso4217-currency-code.ts
│   │   │   ├── is-tax-id.ts
│   │   │   └── isISO6391.ts
│   │   └── typechecker/
│   │       ├── IsArray.ts
│   │       ├── IsBoolean.ts
│   │       ├── IsDate.ts
│   │       ├── IsEnum.ts
│   │       ├── IsInt.ts
│   │       ├── IsNumber.ts
│   │       ├── IsObject.ts
│   │       └── IsString.ts
│   ├── index.ts
│   ├── metadata/
│   │   ├── ConstraintMetadata.ts
│   │   ├── MetadataStorage.ts
│   │   ├── ValidationMetadata.ts
│   │   └── ValidationMetadataArgs.ts
│   ├── register-decorator.ts
│   ├── utils/
│   │   ├── convert-to-array.util.ts
│   │   ├── get-global.util.ts
│   │   ├── index.ts
│   │   └── is-promise.util.ts
│   ├── validation/
│   │   ├── ValidationArguments.ts
│   │   ├── ValidationError.ts
│   │   ├── ValidationExecutor.ts
│   │   ├── ValidationTypes.ts
│   │   ├── ValidationUtils.ts
│   │   ├── Validator.ts
│   │   ├── ValidatorConstraintInterface.ts
│   │   └── ValidatorOptions.ts
│   └── validation-schema/
│       ├── ValidationSchema.ts
│       └── ValidationSchemaToMetadataTransformer.ts
├── test/
│   ├── functional/
│   │   ├── conditional-validation.spec.ts
│   │   ├── custom-decorators.spec.ts
│   │   ├── inherited-validation.spec.ts
│   │   ├── nested-validation.spec.ts
│   │   ├── promise-validation.spec.ts
│   │   ├── reject-validation.spec.ts
│   │   ├── sync-validation.spec.ts
│   │   ├── validation-error.spec.ts
│   │   ├── validation-functions-and-decorators.spec.ts
│   │   ├── validation-options.spec.ts
│   │   ├── validator-options.spec.ts
│   │   └── whitelist-validation.spec.ts
│   └── utils.spec.ts
├── tsconfig.json
├── tsconfig.prod.cjs.json
├── tsconfig.prod.esm2015.json
├── tsconfig.prod.esm5.json
├── tsconfig.prod.json
├── tsconfig.prod.types.json
└── tsconfig.spec.json
Download .txt
SYMBOL INDEX (675 symbols across 162 files)

FILE: sample/sample1-simple-validation/Post.ts
  type PostType (line 15) | enum PostType {
  class Post (line 20) | class Post {

FILE: sample/sample2-using-groups/Post.ts
  class Post (line 3) | class Post {

FILE: sample/sample3-nested-objects/Post.ts
  class Post (line 4) | class Post {

FILE: sample/sample3-nested-objects/Tag.ts
  class Tag (line 3) | class Tag {

FILE: sample/sample4-custom-validator/CustomTextLength.ts
  class CustomTextLength (line 5) | class CustomTextLength implements ValidatorConstraintInterface {
    method validate (line 6) | validate(text: string) {

FILE: sample/sample4-custom-validator/Post.ts
  class Post (line 17) | class Post {

FILE: sample/sample5-schemas/Post.ts
  class Post (line 1) | class Post {

FILE: sample/sample6-custom-decorator/IsLongerThan.ts
  function IsLongerThan (line 7) | function IsLongerThan(property: string, validationOptions?: ValidationOp...
  class IsLongerThanConstraint (line 20) | class IsLongerThanConstraint implements ValidatorConstraintInterface {
    method validate (line 21) | validate(value: any, args: ValidationArguments) {

FILE: sample/sample6-custom-decorator/IsUserAlreadyExist.ts
  function IsUserAlreadyExist (line 5) | function IsUserAlreadyExist(validationOptions?: ValidationOptions) {

FILE: sample/sample6-custom-decorator/User.ts
  class User (line 4) | class User {

FILE: sample/sample7-inheritance-support/BaseContent.ts
  class BaseContent (line 3) | class BaseContent {

FILE: sample/sample7-inheritance-support/Post.ts
  class Post (line 4) | class Post extends BaseContent {

FILE: sample/sample8-es6-maps/Post.ts
  class Post (line 4) | class Post {

FILE: sample/sample8-es6-maps/Tag.ts
  class Tag (line 3) | class Tag {

FILE: sample/sample9-es6-sets/Post.ts
  class Post (line 4) | class Post {

FILE: sample/sample9-es6-sets/Tag.ts
  class Tag (line 3) | class Tag {

FILE: src/container.ts
  type UseContainerOptions (line 4) | interface UseContainerOptions {
  method get (line 22) | get<T>(someClass: { new (...args: any[]): T }): T {
  function useContainer (line 39) | function useContainer(iocContainer: { get(someClass: any): any }, option...
  function getFromContainer (line 47) | function getFromContainer<T>(someClass: { new (...args: any[]): T } | Fu...

FILE: src/decorator/ValidationOptions.ts
  type ValidationOptions (line 6) | interface ValidationOptions {
  function isValidationOptions (line 39) | function isValidationOptions(val: any): val is ValidationOptions {

FILE: src/decorator/array/ArrayContains.ts
  constant ARRAY_CONTAINS (line 4) | const ARRAY_CONTAINS = 'arrayContains';
  function arrayContains (line 10) | function arrayContains(array: unknown, values: any[]): boolean {
  function ArrayContains (line 20) | function ArrayContains(values: any[], validationOptions?: ValidationOpti...

FILE: src/decorator/array/ArrayMaxSize.ts
  constant ARRAY_MAX_SIZE (line 4) | const ARRAY_MAX_SIZE = 'arrayMaxSize';
  function arrayMaxSize (line 10) | function arrayMaxSize(array: unknown, max: number): boolean {
  function ArrayMaxSize (line 18) | function ArrayMaxSize(max: number, validationOptions?: ValidationOptions...

FILE: src/decorator/array/ArrayMinSize.ts
  constant ARRAY_MIN_SIZE (line 4) | const ARRAY_MIN_SIZE = 'arrayMinSize';
  function arrayMinSize (line 10) | function arrayMinSize(array: unknown, min: number): boolean {
  function ArrayMinSize (line 18) | function ArrayMinSize(min: number, validationOptions?: ValidationOptions...

FILE: src/decorator/array/ArrayNotContains.ts
  constant ARRAY_NOT_CONTAINS (line 4) | const ARRAY_NOT_CONTAINS = 'arrayNotContains';
  function arrayNotContains (line 10) | function arrayNotContains(array: unknown, values: any[]): boolean {
  function ArrayNotContains (line 20) | function ArrayNotContains(values: any[], validationOptions?: ValidationO...

FILE: src/decorator/array/ArrayNotEmpty.ts
  constant ARRAY_NOT_EMPTY (line 4) | const ARRAY_NOT_EMPTY = 'arrayNotEmpty';
  function arrayNotEmpty (line 10) | function arrayNotEmpty(array: unknown): boolean {
  function ArrayNotEmpty (line 18) | function ArrayNotEmpty(validationOptions?: ValidationOptions): PropertyD...

FILE: src/decorator/array/ArrayUnique.ts
  constant ARRAY_UNIQUE (line 4) | const ARRAY_UNIQUE = 'arrayUnique';
  type ArrayUniqueIdentifier (line 5) | type ArrayUniqueIdentifier<T = any> = (o: T) => any;
  function arrayUnique (line 11) | function arrayUnique(array: unknown[], identifier?: ArrayUniqueIdentifie...
  function ArrayUnique (line 26) | function ArrayUnique<T = any>(

FILE: src/decorator/common/Allow.ts
  function Allow (line 10) | function Allow(validationOptions?: ValidationOptions): PropertyDecorator {

FILE: src/decorator/common/Equals.ts
  constant EQUALS (line 4) | const EQUALS = 'equals';
  function equals (line 9) | function equals(value: unknown, comparison: unknown): boolean {
  function Equals (line 16) | function Equals(comparison: any, validationOptions?: ValidationOptions):...

FILE: src/decorator/common/IsDefined.ts
  constant IS_DEFINED (line 6) | const IS_DEFINED = ValidationTypes.IS_DEFINED;
  function isDefined (line 11) | function isDefined<T>(value: T | undefined | null): value is T {
  function IsDefined (line 18) | function IsDefined(validationOptions?: ValidationOptions): PropertyDecor...

FILE: src/decorator/common/IsEmpty.ts
  constant IS_EMPTY (line 4) | const IS_EMPTY = 'isEmpty';
  function isEmpty (line 9) | function isEmpty(value: unknown): boolean {
  function IsEmpty (line 16) | function IsEmpty(validationOptions?: ValidationOptions): PropertyDecorat...

FILE: src/decorator/common/IsIn.ts
  constant IS_IN (line 4) | const IS_IN = 'isIn';
  function isIn (line 9) | function isIn(value: unknown, possibleValues: readonly unknown[]): boole...
  function IsIn (line 16) | function IsIn(values: readonly any[], validationOptions?: ValidationOpti...

FILE: src/decorator/common/IsLatLong.ts
  constant IS_LATLONG (line 5) | const IS_LATLONG = 'isLatLong';
  function isLatLong (line 10) | function isLatLong(value: string): boolean {
  function IsLatLong (line 17) | function IsLatLong(validationOptions?: ValidationOptions): PropertyDecor...

FILE: src/decorator/common/IsLatitude.ts
  constant IS_LATITUDE (line 5) | const IS_LATITUDE = 'isLatitude';
  function isLatitude (line 10) | function isLatitude(value: string): boolean {
  function IsLatitude (line 17) | function IsLatitude(validationOptions?: ValidationOptions): PropertyDeco...

FILE: src/decorator/common/IsLongitude.ts
  constant IS_LONGITUDE (line 5) | const IS_LONGITUDE = 'isLongitude';
  function isLongitude (line 10) | function isLongitude(value: string): boolean {
  function IsLongitude (line 17) | function IsLongitude(validationOptions?: ValidationOptions): PropertyDec...

FILE: src/decorator/common/IsNotEmpty.ts
  constant IS_NOT_EMPTY (line 4) | const IS_NOT_EMPTY = 'isNotEmpty';
  function isNotEmpty (line 9) | function isNotEmpty(value: unknown): boolean {
  function IsNotEmpty (line 16) | function IsNotEmpty(validationOptions?: ValidationOptions): PropertyDeco...

FILE: src/decorator/common/IsNotIn.ts
  constant IS_NOT_IN (line 4) | const IS_NOT_IN = 'isNotIn';
  function isNotIn (line 9) | function isNotIn(value: unknown, possibleValues: readonly unknown[]): bo...
  function IsNotIn (line 16) | function IsNotIn(values: readonly any[], validationOptions?: ValidationO...

FILE: src/decorator/common/IsOptional.ts
  constant IS_OPTIONAL (line 7) | const IS_OPTIONAL = 'isOptional';
  function IsOptional (line 12) | function IsOptional(validationOptions?: ValidationOptions): PropertyDeco...

FILE: src/decorator/common/NotEquals.ts
  constant NOT_EQUALS (line 4) | const NOT_EQUALS = 'notEquals';
  function notEquals (line 9) | function notEquals(value: unknown, comparison: unknown): boolean {
  function NotEquals (line 16) | function NotEquals(comparison: any, validationOptions?: ValidationOption...

FILE: src/decorator/common/Validate.ts
  function ValidatorConstraint (line 11) | function ValidatorConstraint(options?: { name?: string; async?: boolean ...
  function Validate (line 36) | function Validate(

FILE: src/decorator/common/ValidateBy.ts
  type ValidateByOptions (line 6) | interface ValidateByOptions {
  function buildMessage (line 13) | function buildMessage(
  function ValidateBy (line 23) | function ValidateBy(options: ValidateByOptions, validationOptions?: Vali...

FILE: src/decorator/common/ValidateIf.ts
  function ValidateIf (line 10) | function ValidateIf(

FILE: src/decorator/common/ValidateNested.ts
  function ValidateNested (line 10) | function ValidateNested(validationOptions?: ValidationOptions): Property...

FILE: src/decorator/common/ValidatePromise.ts
  function ValidatePromise (line 10) | function ValidatePromise(validationOptions?: ValidationOptions): Propert...

FILE: src/decorator/date/MaxDate.ts
  constant MAX_DATE (line 4) | const MAX_DATE = 'maxDate';
  function maxDate (line 9) | function maxDate(date: unknown, maxDate: Date | (() => Date)): boolean {
  function MaxDate (line 16) | function MaxDate(date: Date | (() => Date), validationOptions?: Validati...

FILE: src/decorator/date/MinDate.ts
  constant MIN_DATE (line 4) | const MIN_DATE = 'minDate';
  function minDate (line 9) | function minDate(date: unknown, minDate: Date | (() => Date)): boolean {
  function MinDate (line 16) | function MinDate(date: Date | (() => Date), validationOptions?: Validati...

FILE: src/decorator/number/IsDivisibleBy.ts
  constant IS_DIVISIBLE_BY (line 5) | const IS_DIVISIBLE_BY = 'isDivisibleBy';
  function isDivisibleBy (line 10) | function isDivisibleBy(value: unknown, num: number): boolean {
  function IsDivisibleBy (line 17) | function IsDivisibleBy(num: number, validationOptions?: ValidationOption...

FILE: src/decorator/number/IsNegative.ts
  constant IS_NEGATIVE (line 4) | const IS_NEGATIVE = 'isNegative';
  function isNegative (line 9) | function isNegative(value: unknown): boolean {
  function IsNegative (line 16) | function IsNegative(validationOptions?: ValidationOptions): PropertyDeco...

FILE: src/decorator/number/IsPositive.ts
  constant IS_POSITIVE (line 4) | const IS_POSITIVE = 'isPositive';
  function isPositive (line 9) | function isPositive(value: unknown): boolean {
  function IsPositive (line 16) | function IsPositive(validationOptions?: ValidationOptions): PropertyDeco...

FILE: src/decorator/number/Max.ts
  constant MAX (line 4) | const MAX = 'max';
  function max (line 9) | function max(num: unknown, max: number): boolean {
  function Max (line 16) | function Max(maxValue: number, validationOptions?: ValidationOptions): P...

FILE: src/decorator/number/Min.ts
  constant MIN (line 4) | const MIN = 'min';
  function min (line 9) | function min(num: unknown, min: number): boolean {
  function Min (line 16) | function Min(minValue: number, validationOptions?: ValidationOptions): P...

FILE: src/decorator/object/IsInstance.ts
  constant IS_INSTANCE (line 4) | const IS_INSTANCE = 'isInstance';
  function isInstance (line 9) | function isInstance(object: unknown, targetTypeConstructor: new (...args...
  function IsInstance (line 18) | function IsInstance(

FILE: src/decorator/object/IsNotEmptyObject.ts
  constant IS_NOT_EMPTY_OBJECT (line 5) | const IS_NOT_EMPTY_OBJECT = 'isNotEmptyObject';
  function isNotEmptyObject (line 11) | function isNotEmptyObject(value: unknown, options?: { nullable?: boolean...
  function IsNotEmptyObject (line 33) | function IsNotEmptyObject(

FILE: src/decorator/string/Contains.ts
  constant CONTAINS (line 5) | const CONTAINS = 'contains';
  function contains (line 11) | function contains(value: unknown, seed: string): boolean {
  function Contains (line 19) | function Contains(seed: string, validationOptions?: ValidationOptions): ...

FILE: src/decorator/string/IsAlpha.ts
  constant IS_ALPHA (line 6) | const IS_ALPHA = 'isAlpha';
  function isAlpha (line 12) | function isAlpha(value: unknown, locale?: ValidatorJS.AlphaLocale): bool...
  function IsAlpha (line 20) | function IsAlpha(locale?: ValidatorJS.AlphaLocale, validationOptions?: V...

FILE: src/decorator/string/IsAlphanumeric.ts
  constant IS_ALPHANUMERIC (line 6) | const IS_ALPHANUMERIC = 'isAlphanumeric';
  function isAlphanumeric (line 12) | function isAlphanumeric(value: unknown, locale?: ValidatorJS.Alphanumeri...
  function IsAlphanumeric (line 20) | function IsAlphanumeric(

FILE: src/decorator/string/IsAscii.ts
  constant IS_ASCII (line 5) | const IS_ASCII = 'isAscii';
  function isAscii (line 11) | function isAscii(value: unknown): boolean {
  function IsAscii (line 19) | function IsAscii(validationOptions?: ValidationOptions): PropertyDecorat...

FILE: src/decorator/string/IsBIC.ts
  constant IS_BIC (line 5) | const IS_BIC = 'isBIC';
  function isBIC (line 11) | function isBIC(value: unknown): boolean {
  function IsBIC (line 19) | function IsBIC(validationOptions?: ValidationOptions): PropertyDecorator {

FILE: src/decorator/string/IsBase32.ts
  constant IS_BASE32 (line 5) | const IS_BASE32 = 'isBase32';
  function isBase32 (line 11) | function isBase32(value: unknown): boolean {
  function IsBase32 (line 19) | function IsBase32(validationOptions?: ValidationOptions): PropertyDecora...

FILE: src/decorator/string/IsBase58.ts
  constant IS_BASE58 (line 5) | const IS_BASE58 = 'isBase58';
  function isBase58 (line 11) | function isBase58(value: unknown): boolean {
  function IsBase58 (line 19) | function IsBase58(validationOptions?: ValidationOptions): PropertyDecora...

FILE: src/decorator/string/IsBase64.ts
  constant IS_BASE64 (line 6) | const IS_BASE64 = 'isBase64';
  function isBase64 (line 12) | function isBase64(value: unknown, options?: ValidatorJS.IsBase64Options)...
  function IsBase64 (line 20) | function IsBase64(

FILE: src/decorator/string/IsBooleanString.ts
  constant IS_BOOLEAN_STRING (line 5) | const IS_BOOLEAN_STRING = 'isBooleanString';
  function isBooleanString (line 11) | function isBooleanString(value: unknown): boolean {
  function IsBooleanString (line 19) | function IsBooleanString(validationOptions?: ValidationOptions): Propert...

FILE: src/decorator/string/IsBtcAddress.ts
  constant IS_BTC_ADDRESS (line 5) | const IS_BTC_ADDRESS = 'isBtcAddress';
  function isBtcAddress (line 11) | function isBtcAddress(value: unknown): boolean {
  function IsBtcAddress (line 19) | function IsBtcAddress(validationOptions?: ValidationOptions): PropertyDe...

FILE: src/decorator/string/IsByteLength.ts
  constant IS_BYTE_LENGTH (line 5) | const IS_BYTE_LENGTH = 'isByteLength';
  function isByteLength (line 11) | function isByteLength(value: unknown, min: number, max?: number): boolean {
  function IsByteLength (line 19) | function IsByteLength(min: number, max?: number, validationOptions?: Val...

FILE: src/decorator/string/IsCreditCard.ts
  constant IS_CREDIT_CARD (line 5) | const IS_CREDIT_CARD = 'isCreditCard';
  function isCreditCard (line 11) | function isCreditCard(value: unknown): boolean {
  function IsCreditCard (line 19) | function IsCreditCard(validationOptions?: ValidationOptions): PropertyDe...

FILE: src/decorator/string/IsCurrency.ts
  constant IS_CURRENCY (line 6) | const IS_CURRENCY = 'isCurrency';
  function isCurrency (line 12) | function isCurrency(value: unknown, options?: ValidatorJS.IsCurrencyOpti...
  function IsCurrency (line 20) | function IsCurrency(

FILE: src/decorator/string/IsDataURI.ts
  constant IS_DATA_URI (line 5) | const IS_DATA_URI = 'isDataURI';
  function isDataURI (line 11) | function isDataURI(value: unknown): boolean {
  function IsDataURI (line 19) | function IsDataURI(validationOptions?: ValidationOptions): PropertyDecor...

FILE: src/decorator/string/IsDateString.ts
  constant IS_DATE_STRING (line 6) | const IS_DATE_STRING = 'isDateString';
  function isDateString (line 11) | function isDateString(value: unknown, options?: ValidatorJS.IsISO8601Opt...
  function IsDateString (line 18) | function IsDateString(

FILE: src/decorator/string/IsDecimal.ts
  constant IS_DECIMAL (line 6) | const IS_DECIMAL = 'isDecimal';
  function isDecimal (line 12) | function isDecimal(value: unknown, options?: ValidatorJS.IsDecimalOption...
  function IsDecimal (line 20) | function IsDecimal(

FILE: src/decorator/string/IsEAN.ts
  constant IS_EAN (line 5) | const IS_EAN = 'isEAN';
  function isEAN (line 11) | function isEAN(value: unknown): boolean {
  function IsEAN (line 19) | function IsEAN(validationOptions?: ValidationOptions): PropertyDecorator {

FILE: src/decorator/string/IsEmail.ts
  constant IS_EMAIL (line 6) | const IS_EMAIL = 'isEmail';
  function isEmail (line 12) | function isEmail(value: unknown, options?: ValidatorJS.IsEmailOptions): ...
  function IsEmail (line 20) | function IsEmail(

FILE: src/decorator/string/IsEthereumAddress.ts
  constant IS_ETHEREUM_ADDRESS (line 5) | const IS_ETHEREUM_ADDRESS = 'isEthereumAddress';
  function isEthereumAddress (line 11) | function isEthereumAddress(value: unknown): boolean {
  function IsEthereumAddress (line 19) | function IsEthereumAddress(validationOptions?: ValidationOptions): Prope...

FILE: src/decorator/string/IsFQDN.ts
  constant IS_FQDN (line 6) | const IS_FQDN = 'isFqdn';
  function isFQDN (line 12) | function isFQDN(value: unknown, options?: ValidatorJS.IsFQDNOptions): bo...
  function IsFQDN (line 20) | function IsFQDN(options?: ValidatorJS.IsFQDNOptions, validationOptions?:...

FILE: src/decorator/string/IsFirebasePushId.ts
  constant IS_FIREBASE_PUSH_ID (line 4) | const IS_FIREBASE_PUSH_ID = 'IsFirebasePushId';
  function isFirebasePushId (line 10) | function isFirebasePushId(value: unknown): boolean {
  function IsFirebasePushId (line 19) | function IsFirebasePushId(validationOptions?: ValidationOptions): Proper...

FILE: src/decorator/string/IsFullWidth.ts
  constant IS_FULL_WIDTH (line 5) | const IS_FULL_WIDTH = 'isFullWidth';
  function isFullWidth (line 11) | function isFullWidth(value: unknown): boolean {
  function IsFullWidth (line 19) | function IsFullWidth(validationOptions?: ValidationOptions): PropertyDec...

FILE: src/decorator/string/IsHSL.ts
  constant IS_HSL (line 5) | const IS_HSL = 'isHSL';
  function isHSL (line 12) | function isHSL(value: unknown): boolean {
  function IsHSL (line 21) | function IsHSL(validationOptions?: ValidationOptions): PropertyDecorator {

FILE: src/decorator/string/IsHalfWidth.ts
  constant IS_HALF_WIDTH (line 5) | const IS_HALF_WIDTH = 'isHalfWidth';
  function isHalfWidth (line 11) | function isHalfWidth(value: unknown): boolean {
  function IsHalfWidth (line 19) | function IsHalfWidth(validationOptions?: ValidationOptions): PropertyDec...

FILE: src/decorator/string/IsHash.ts
  constant IS_HASH (line 6) | const IS_HASH = 'isHash';
  function isHash (line 13) | function isHash(value: unknown, algorithm: ValidatorJS.HashAlgorithm): b...
  function IsHash (line 22) | function IsHash(algorithm: string, validationOptions?: ValidationOptions...

FILE: src/decorator/string/IsHexColor.ts
  constant IS_HEX_COLOR (line 5) | const IS_HEX_COLOR = 'isHexColor';
  function isHexColor (line 11) | function isHexColor(value: unknown): boolean {
  function IsHexColor (line 19) | function IsHexColor(validationOptions?: ValidationOptions): PropertyDeco...

FILE: src/decorator/string/IsHexadecimal.ts
  constant IS_HEXADECIMAL (line 5) | const IS_HEXADECIMAL = 'isHexadecimal';
  function isHexadecimal (line 11) | function isHexadecimal(value: unknown): boolean {
  function IsHexadecimal (line 19) | function IsHexadecimal(validationOptions?: ValidationOptions): PropertyD...

FILE: src/decorator/string/IsIBAN.ts
  constant IS_IBAN (line 5) | const IS_IBAN = 'isIBAN';
  function isIBAN (line 11) | function isIBAN(value: unknown, options?: IsIBANOptions): boolean {
  function IsIBAN (line 19) | function IsIBAN(options?: IsIBANOptions, validationOptions?: ValidationO...

FILE: src/decorator/string/IsIP.ts
  type IsIpVersion (line 5) | type IsIpVersion = '4' | '6' | 4 | 6;
  constant IS_IP (line 7) | const IS_IP = 'isIp';
  function isIP (line 13) | function isIP(value: unknown, version?: IsIpVersion): boolean {
  function IsIP (line 23) | function IsIP(version?: IsIpVersion, validationOptions?: ValidationOptio...

FILE: src/decorator/string/IsISBN.ts
  type IsISBNVersion (line 5) | type IsISBNVersion = '10' | '13' | 10 | 13;
  constant IS_ISBN (line 7) | const IS_ISBN = 'isIsbn';
  function isISBN (line 13) | function isISBN(value: unknown, version?: IsISBNVersion): boolean {
  function IsISBN (line 23) | function IsISBN(version?: IsISBNVersion, validationOptions?: ValidationO...

FILE: src/decorator/string/IsISIN.ts
  constant IS_ISIN (line 5) | const IS_ISIN = 'isIsin';
  function isISIN (line 11) | function isISIN(value: unknown): boolean {
  function IsISIN (line 19) | function IsISIN(validationOptions?: ValidationOptions): PropertyDecorator {

FILE: src/decorator/string/IsISO31661Alpha2.ts
  constant IS_ISO31661_ALPHA_2 (line 5) | const IS_ISO31661_ALPHA_2 = 'isISO31661Alpha2';
  function isISO31661Alpha2 (line 10) | function isISO31661Alpha2(value: unknown): boolean {
  function IsISO31661Alpha2 (line 17) | function IsISO31661Alpha2(validationOptions?: ValidationOptions): Proper...

FILE: src/decorator/string/IsISO31661Alpha3.ts
  constant IS_ISO31661_ALPHA_3 (line 5) | const IS_ISO31661_ALPHA_3 = 'isISO31661Alpha3';
  function isISO31661Alpha3 (line 10) | function isISO31661Alpha3(value: unknown): boolean {
  function IsISO31661Alpha3 (line 17) | function IsISO31661Alpha3(validationOptions?: ValidationOptions): Proper...

FILE: src/decorator/string/IsISO31661Numeric.ts
  constant IS_ISO31661_NUMERIC (line 5) | const IS_ISO31661_NUMERIC = 'isISO31661Numeric';
  function isISO31661Numeric (line 10) | function isISO31661Numeric(value: unknown): boolean {
  function IsISO31661Numeric (line 17) | function IsISO31661Numeric(validationOptions?: ValidationOptions): Prope...

FILE: src/decorator/string/IsISO8601.ts
  constant IS_ISO8601 (line 6) | const IS_ISO8601 = 'isIso8601';
  function isISO8601 (line 13) | function isISO8601(value: unknown, options?: ValidatorJS.IsISO8601Option...
  function IsISO8601 (line 22) | function IsISO8601(

FILE: src/decorator/string/IsISRC.ts
  constant IS_ISRC (line 5) | const IS_ISRC = 'isISRC';
  function isISRC (line 11) | function isISRC(value: unknown): boolean {
  function IsISRC (line 19) | function IsISRC(validationOptions?: ValidationOptions): PropertyDecorator {

FILE: src/decorator/string/IsISSN.ts
  constant IS_ISSN (line 6) | const IS_ISSN = 'isISSN';
  function isISSN (line 12) | function isISSN(value: unknown, options?: ValidatorJS.IsISSNOptions): bo...
  function IsISSN (line 20) | function IsISSN(options?: ValidatorJS.IsISSNOptions, validationOptions?:...

FILE: src/decorator/string/IsIdentityCard.ts
  constant IS_IDENTITY_CARD (line 6) | const IS_IDENTITY_CARD = 'isIdentityCard';
  function isIdentityCard (line 14) | function isIdentityCard(value: unknown, locale: ValidatorJS.IdentityCard...
  function IsIdentityCard (line 24) | function IsIdentityCard(

FILE: src/decorator/string/IsJSON.ts
  constant IS_JSON (line 5) | const IS_JSON = 'isJson';
  function isJSON (line 11) | function isJSON(value: unknown): boolean {
  function IsJSON (line 19) | function IsJSON(validationOptions?: ValidationOptions): PropertyDecorator {

FILE: src/decorator/string/IsJWT.ts
  constant IS_JWT (line 5) | const IS_JWT = 'isJwt';
  function isJWT (line 11) | function isJWT(value: unknown): boolean {
  function IsJWT (line 19) | function IsJWT(validationOptions?: ValidationOptions): PropertyDecorator {

FILE: src/decorator/string/IsLocale.ts
  constant IS_LOCALE (line 5) | const IS_LOCALE = 'isLocale';
  function isLocale (line 11) | function isLocale(value: unknown): boolean {
  function IsLocale (line 19) | function IsLocale(validationOptions?: ValidationOptions): PropertyDecora...

FILE: src/decorator/string/IsLowercase.ts
  constant IS_LOWERCASE (line 5) | const IS_LOWERCASE = 'isLowercase';
  function isLowercase (line 11) | function isLowercase(value: unknown): boolean {
  function IsLowercase (line 19) | function IsLowercase(validationOptions?: ValidationOptions): PropertyDec...

FILE: src/decorator/string/IsMacAddress.ts
  constant IS_MAC_ADDRESS (line 6) | const IS_MAC_ADDRESS = 'isMacAddress';
  function isMACAddress (line 12) | function isMACAddress(value: unknown, options?: ValidatorJS.IsMACAddress...
  function IsMACAddress (line 25) | function IsMACAddress(

FILE: src/decorator/string/IsMagnetURI.ts
  constant IS_MAGNET_URI (line 5) | const IS_MAGNET_URI = 'isMagnetURI';
  function isMagnetURI (line 11) | function isMagnetURI(value: unknown): boolean {
  function IsMagnetURI (line 19) | function IsMagnetURI(validationOptions?: ValidationOptions): PropertyDec...

FILE: src/decorator/string/IsMilitaryTime.ts
  constant IS_MILITARY_TIME (line 5) | const IS_MILITARY_TIME = 'isMilitaryTime';
  function isMilitaryTime (line 11) | function isMilitaryTime(value: unknown): boolean {
  function IsMilitaryTime (line 20) | function IsMilitaryTime(validationOptions?: ValidationOptions): Property...

FILE: src/decorator/string/IsMimeType.ts
  constant IS_MIME_TYPE (line 5) | const IS_MIME_TYPE = 'isMimeType';
  function isMimeType (line 11) | function isMimeType(value: unknown): boolean {
  function IsMimeType (line 19) | function IsMimeType(validationOptions?: ValidationOptions): PropertyDeco...

FILE: src/decorator/string/IsMobilePhone.ts
  constant IS_MOBILE_PHONE (line 6) | const IS_MOBILE_PHONE = 'isMobilePhone';
  function isMobilePhone (line 20) | function isMobilePhone(
  function IsMobilePhone (line 40) | function IsMobilePhone(

FILE: src/decorator/string/IsMongoId.ts
  constant IS_MONGO_ID (line 5) | const IS_MONGO_ID = 'isMongoId';
  function isMongoId (line 11) | function isMongoId(value: unknown): boolean {
  function IsMongoId (line 19) | function IsMongoId(validationOptions?: ValidationOptions): PropertyDecor...

FILE: src/decorator/string/IsMultibyte.ts
  constant IS_MULTIBYTE (line 5) | const IS_MULTIBYTE = 'isMultibyte';
  function isMultibyte (line 11) | function isMultibyte(value: unknown): boolean {
  function IsMultibyte (line 19) | function IsMultibyte(validationOptions?: ValidationOptions): PropertyDec...

FILE: src/decorator/string/IsNumberString.ts
  constant IS_NUMBER_STRING (line 6) | const IS_NUMBER_STRING = 'isNumberString';
  function isNumberString (line 12) | function isNumberString(value: unknown, options?: ValidatorJS.IsNumericO...
  function IsNumberString (line 20) | function IsNumberString(

FILE: src/decorator/string/IsOctal.ts
  constant IS_OCTAL (line 5) | const IS_OCTAL = 'isOctal';
  function isOctal (line 11) | function isOctal(value: unknown): boolean {
  function IsOctal (line 19) | function IsOctal(validationOptions?: ValidationOptions): PropertyDecorat...

FILE: src/decorator/string/IsPassportNumber.ts
  constant IS_PASSPORT_NUMBER (line 5) | const IS_PASSPORT_NUMBER = 'isPassportNumber';
  function isPassportNumber (line 11) | function isPassportNumber(value: unknown, countryCode: string): boolean {
  function IsPassportNumber (line 19) | function IsPassportNumber(countryCode: string, validationOptions?: Valid...

FILE: src/decorator/string/IsPhoneNumber.ts
  constant IS_PHONE_NUMBER (line 5) | const IS_PHONE_NUMBER = 'isPhoneNumber';
  function isPhoneNumber (line 15) | function isPhoneNumber(value: string, region?: CountryCode): boolean {
  function IsPhoneNumber (line 44) | function IsPhoneNumber(region?: CountryCode, validationOptions?: Validat...

FILE: src/decorator/string/IsPort.ts
  constant IS_PORT (line 5) | const IS_PORT = 'isPort';
  function isPort (line 10) | function isPort(value: unknown): boolean {
  function IsPort (line 17) | function IsPort(validationOptions?: ValidationOptions): PropertyDecorator {

FILE: src/decorator/string/IsPostalCode.ts
  constant IS_POSTAL_CODE (line 6) | const IS_POSTAL_CODE = 'isPostalCode';
  function isPostalCode (line 12) | function isPostalCode(value: unknown, locale: 'any' | ValidatorJS.Postal...
  function IsPostalCode (line 20) | function IsPostalCode(

FILE: src/decorator/string/IsRFC3339.ts
  constant IS_RFC_3339 (line 5) | const IS_RFC_3339 = 'isRFC3339';
  function isRFC3339 (line 11) | function isRFC3339(value: unknown): boolean {
  function IsRFC3339 (line 19) | function IsRFC3339(validationOptions?: ValidationOptions): PropertyDecor...

FILE: src/decorator/string/IsRgbColor.ts
  constant IS_RGB_COLOR (line 5) | const IS_RGB_COLOR = 'isRgbColor';
  function isRgbColor (line 12) | function isRgbColor(value: unknown, includePercentValues?: boolean): boo...
  function IsRgbColor (line 26) | function IsRgbColor(includePercentValues?: boolean, validationOptions?: ...

FILE: src/decorator/string/IsSemVer.ts
  constant IS_SEM_VER (line 5) | const IS_SEM_VER = 'isSemVer';
  function isSemVer (line 11) | function isSemVer(value: unknown): boolean {
  function IsSemVer (line 19) | function IsSemVer(validationOptions?: ValidationOptions): PropertyDecora...

FILE: src/decorator/string/IsStrongPassword.ts
  constant IS_STRONG_PASSWORD (line 5) | const IS_STRONG_PASSWORD = 'isStrongPassword';
  type IsStrongPasswordOptions (line 10) | type IsStrongPasswordOptions = Pick<
  function isStrongPassword (line 19) | function isStrongPassword(value: unknown, options?: IsStrongPasswordOpti...
  function IsStrongPassword (line 27) | function IsStrongPassword(

FILE: src/decorator/string/IsSurrogatePair.ts
  constant IS_SURROGATE_PAIR (line 5) | const IS_SURROGATE_PAIR = 'isSurrogatePair';
  function isSurrogatePair (line 11) | function isSurrogatePair(value: unknown): boolean {
  function IsSurrogatePair (line 19) | function IsSurrogatePair(validationOptions?: ValidationOptions): Propert...

FILE: src/decorator/string/IsTimeZone.ts
  constant IS_TIMEZONE (line 4) | const IS_TIMEZONE = 'isTimeZone';
  function isTimeZone (line 10) | function isTimeZone(value: unknown): boolean {
  function IsTimeZone (line 29) | function IsTimeZone(validationOptions?: ValidationOptions): PropertyDeco...

FILE: src/decorator/string/IsUUID.ts
  constant IS_UUID (line 6) | const IS_UUID = 'isUuid';
  type IsUUIDVersion (line 8) | type IsUUIDVersion = ValidatorJS.UUIDVersion | ValidatorJS.UUIDVersion[];
  function isUUID (line 15) | function isUUID(value: unknown, version?: IsUUIDVersion): boolean {
  function IsUUID (line 31) | function IsUUID(version?: IsUUIDVersion, validationOptions?: ValidationO...

FILE: src/decorator/string/IsUppercase.ts
  constant IS_UPPERCASE (line 5) | const IS_UPPERCASE = 'isUppercase';
  function isUppercase (line 11) | function isUppercase(value: unknown): boolean {
  function IsUppercase (line 19) | function IsUppercase(validationOptions?: ValidationOptions): PropertyDec...

FILE: src/decorator/string/IsUrl.ts
  constant IS_URL (line 6) | const IS_URL = 'isUrl';
  function isURL (line 12) | function isURL(value: string, options?: ValidatorJS.IsURLOptions): boole...
  function IsUrl (line 20) | function IsUrl(options?: ValidatorJS.IsURLOptions, validationOptions?: V...

FILE: src/decorator/string/IsVariableWidth.ts
  constant IS_VARIABLE_WIDTH (line 5) | const IS_VARIABLE_WIDTH = 'isVariableWidth';
  function isVariableWidth (line 11) | function isVariableWidth(value: unknown): boolean {
  function IsVariableWidth (line 19) | function IsVariableWidth(validationOptions?: ValidationOptions): Propert...

FILE: src/decorator/string/Length.ts
  constant IS_LENGTH (line 5) | const IS_LENGTH = 'isLength';
  function length (line 11) | function length(value: unknown, min: number, max?: number): boolean {
  function Length (line 19) | function Length(min: number, max?: number, validationOptions?: Validatio...

FILE: src/decorator/string/Matches.ts
  constant MATCHES (line 5) | const MATCHES = 'matches';
  function matches (line 13) | function matches(value: string, pattern: RegExp | string, modifiers?: st...
  function Matches (line 23) | function Matches(

FILE: src/decorator/string/MaxLength.ts
  constant MAX_LENGTH (line 5) | const MAX_LENGTH = 'maxLength';
  function maxLength (line 11) | function maxLength(value: unknown, max: number): boolean {
  function MaxLength (line 19) | function MaxLength(max: number, validationOptions?: ValidationOptions): ...

FILE: src/decorator/string/MinLength.ts
  constant MIN_LENGTH (line 5) | const MIN_LENGTH = 'minLength';
  function minLength (line 11) | function minLength(value: unknown, min: number): boolean {
  function MinLength (line 19) | function MinLength(min: number, validationOptions?: ValidationOptions): ...

FILE: src/decorator/string/NotContains.ts
  constant NOT_CONTAINS (line 5) | const NOT_CONTAINS = 'notContains';
  function notContains (line 11) | function notContains(value: unknown, seed: string): boolean {
  function NotContains (line 19) | function NotContains(seed: string, validationOptions?: ValidationOptions...

FILE: src/decorator/string/is-iso4217-currency-code.ts
  constant IS_ISO4217_CURRENCY_CODE (line 5) | const IS_ISO4217_CURRENCY_CODE = 'isISO4217CurrencyCode';
  function isISO4217CurrencyCode (line 10) | function isISO4217CurrencyCode(value: unknown): boolean {
  function IsISO4217CurrencyCode (line 17) | function IsISO4217CurrencyCode(validationOptions?: ValidationOptions): P...

FILE: src/decorator/string/is-tax-id.ts
  constant IS_TAX_ID (line 5) | const IS_TAX_ID = 'isTaxId';
  function isTaxId (line 15) | function isTaxId(value: unknown, locale?: string): boolean {
  function IsTaxId (line 27) | function IsTaxId(locale?: string, validationOptions?: ValidationOptions)...

FILE: src/decorator/string/isISO6391.ts
  constant IS_ISO6391 (line 5) | const IS_ISO6391 = 'isISO6391';
  function isISO6391 (line 10) | function isISO6391(value: unknown): boolean {
  function IsISO6391 (line 17) | function IsISO6391(validationOptions?: ValidationOptions): PropertyDecor...

FILE: src/decorator/typechecker/IsArray.ts
  constant IS_ARRAY (line 4) | const IS_ARRAY = 'isArray';
  function isArray (line 9) | function isArray<T = any>(value: unknown): value is Array<T> {
  function IsArray (line 16) | function IsArray(validationOptions?: ValidationOptions): PropertyDecorat...

FILE: src/decorator/typechecker/IsBoolean.ts
  constant IS_BOOLEAN (line 4) | const IS_BOOLEAN = 'isBoolean';
  function isBoolean (line 9) | function isBoolean(value: unknown): value is boolean {
  function IsBoolean (line 16) | function IsBoolean(validationOptions?: ValidationOptions): PropertyDecor...

FILE: src/decorator/typechecker/IsDate.ts
  constant IS_DATE (line 4) | const IS_DATE = 'isDate';
  function isDate (line 9) | function isDate(value: unknown): value is Date {
  function IsDate (line 16) | function IsDate(validationOptions?: ValidationOptions): PropertyDecorator {

FILE: src/decorator/typechecker/IsEnum.ts
  constant IS_ENUM (line 4) | const IS_ENUM = 'isEnum';
  function isEnum (line 9) | function isEnum(value: unknown, entity: any): boolean {
  function validEnumValues (line 17) | function validEnumValues(entity: any): string[] {
  function IsEnum (line 26) | function IsEnum(entity: object, validationOptions?: ValidationOptions): ...

FILE: src/decorator/typechecker/IsInt.ts
  constant IS_INT (line 4) | const IS_INT = 'isInt';
  function isInt (line 9) | function isInt(val: unknown): val is Number {
  function IsInt (line 16) | function IsInt(validationOptions?: ValidationOptions): PropertyDecorator {

FILE: src/decorator/typechecker/IsNumber.ts
  constant IS_NUMBER (line 4) | const IS_NUMBER = 'isNumber';
  type IsNumberOptions (line 9) | interface IsNumberOptions {
  function isNumber (line 18) | function isNumber(value: unknown, options: IsNumberOptions = {}): value ...
  function IsNumber (line 47) | function IsNumber(options: IsNumberOptions = {}, validationOptions?: Val...

FILE: src/decorator/typechecker/IsObject.ts
  constant IS_OBJECT (line 4) | const IS_OBJECT = 'isObject';
  function isObject (line 10) | function isObject<T = object>(value: unknown): value is T {
  function IsObject (line 18) | function IsObject(validationOptions?: ValidationOptions): PropertyDecora...

FILE: src/decorator/typechecker/IsString.ts
  constant IS_STRING (line 4) | const IS_STRING = 'isString';
  function isString (line 9) | function isString(value: unknown): value is string {
  function IsString (line 16) | function IsString(validationOptions?: ValidationOptions): PropertyDecora...

FILE: src/index.ts
  function validate (line 46) | function validate(
  function validateOrReject (line 79) | function validateOrReject(
  function validateSync (line 121) | function validateSync(
  function registerSchema (line 140) | function registerSchema(schema: ValidationSchema): void {

FILE: src/metadata/ConstraintMetadata.ts
  class ConstraintMetadata (line 7) | class ConstraintMetadata {
    method constructor (line 31) | constructor(target: Function, name?: string, async: boolean = false) {
    method instance (line 44) | get instance(): ValidatorConstraintInterface {

FILE: src/metadata/MetadataStorage.ts
  class MetadataStorage (line 10) | class MetadataStorage {
    method hasValidationMetaData (line 18) | get hasValidationMetaData(): boolean {
    method addValidationSchema (line 29) | addValidationSchema(schema: ValidationSchema): void {
    method addValidationMetadata (line 37) | addValidationMetadata(metadata: ValidationMetadata): void {
    method addConstraintMetadata (line 50) | addConstraintMetadata(metadata: ConstraintMetadata): void {
    method groupByPropertyName (line 63) | groupByPropertyName(metadata: ValidationMetadata[]): { [propertyName: ...
    method getTargetValidationMetadatas (line 75) | getTargetValidationMetadatas(
    method getTargetValidatorConstraints (line 154) | getTargetValidatorConstraints(target: Function): ConstraintMetadata[] {
  function getMetadataStorage (line 163) | function getMetadataStorage(): MetadataStorage {

FILE: src/metadata/ValidationMetadata.ts
  class ValidationMetadata (line 7) | class ValidationMetadata {
    method constructor (line 81) | constructor(args: ValidationMetadataArgs) {

FILE: src/metadata/ValidationMetadataArgs.ts
  type ValidationMetadataArgs (line 6) | interface ValidationMetadataArgs {

FILE: src/register-decorator.ts
  type ValidationDecoratorOptions (line 11) | interface ValidationDecoratorOptions {
  function registerDecorator (line 51) | function registerDecorator(options: ValidationDecoratorOptions): void {

FILE: src/utils/convert-to-array.util.ts
  function convertToArray (line 4) | function convertToArray<T>(val: Array<T> | Set<T> | Map<any, T>): Array<...

FILE: src/utils/get-global.util.ts
  function getGlobal (line 7) | function getGlobal() {

FILE: src/utils/is-promise.util.ts
  function isPromise (line 3) | function isPromise<T = any>(p: any): p is Promise<T> {

FILE: src/validation-schema/ValidationSchema.ts
  type ValidationSchema (line 5) | interface ValidationSchema {

FILE: src/validation-schema/ValidationSchemaToMetadataTransformer.ts
  class ValidationSchemaToMetadataTransformer (line 9) | class ValidationSchemaToMetadataTransformer {
    method transform (line 10) | transform(schema: ValidationSchema): ValidationMetadata[] {

FILE: src/validation/ValidationArguments.ts
  type ValidationArguments (line 5) | interface ValidationArguments {

FILE: src/validation/ValidationError.ts
  class ValidationError (line 4) | class ValidationError {
    method toString (line 50) | toString(

FILE: src/validation/ValidationExecutor.ts
  class ValidationExecutor (line 15) | class ValidationExecutor {
    method constructor (line 33) | constructor(private validator: Validator, private validatorOptions?: V...
    method execute (line 39) | execute(object: object, targetSchema: string, validationErrors: Valida...
    method whitelist (line 119) | whitelist(
    method stripEmptyErrors (line 148) | stripEmptyErrors(errors: ValidationError[]): ValidationError[] {
    method performValidations (line 170) | private performValidations(
    method generateValidationError (line 219) | private generateValidationError(object: object, value: any, propertyNa...
    method conditionalValidations (line 245) | private conditionalValidations(object: object, value: any, metadatas: ...
    method customValidations (line 251) | private customValidations(object: object, value: any, metadatas: Valid...
    method nestedValidations (line 349) | private nestedValidations(value: any, metadatas: ValidationMetadata[],...
    method mapContexts (line 381) | private mapContexts(object: object, value: any, metadatas: ValidationM...
    method createValidationError (line 403) | private createValidationError(
    method getConstraintType (line 433) | private getConstraintType(metadata: ValidationMetadata, customValidato...

FILE: src/validation/ValidationTypes.ts
  class ValidationTypes (line 4) | class ValidationTypes {
    method isValid (line 16) | static isValid(type: string): boolean {

FILE: src/validation/ValidationUtils.ts
  function constraintToString (line 6) | function constraintToString(constraint: unknown): string {
  class ValidationUtils (line 18) | class ValidationUtils {
    method replaceMessageSpecialTokens (line 19) | static replaceMessageSpecialTokens(

FILE: src/validation/Validator.ts
  class Validator (line 9) | class Validator {
    method validate (line 27) | validate(
    method validateOrReject (line 48) | async validateOrReject(
    method validateSync (line 71) | validateSync(
    method coreValidate (line 95) | private coreValidate(

FILE: src/validation/ValidatorConstraintInterface.ts
  type ValidatorConstraintInterface (line 5) | interface ValidatorConstraintInterface {

FILE: src/validation/ValidatorOptions.ts
  type ValidatorOptions (line 4) | interface ValidatorOptions {

FILE: test/functional/conditional-validation.spec.ts
  class MyClass (line 10) | class MyClass {
  class MyClass (line 25) | class MyClass {
  class MyClass (line 44) | class MyClass {
  class MyClass (line 63) | class MyClass {
  class MyClass (line 80) | class MyClass {

FILE: test/functional/custom-decorators.spec.ts
  function IsLongerThan (line 11) | function IsLongerThan(property: string, validationOptions?: ValidationOp...
  class MyClass (line 39) | class MyClass {
  class MyClassWithAsyncValidator (line 48) | class MyClassWithAsyncValidator {
  function IsLonger (line 109) | function IsLonger(property: string, validationOptions?: ValidationOption...
  class SecondClass (line 133) | class SecondClass {
  class IsShortenThanConstraint (line 172) | @ValidatorConstraint({ name: 'isShortenThan' })
    method validate (line 174) | validate(value: any, args: ValidationArguments): boolean {
  function IsShorterThan (line 183) | function IsShorterThan(property: string, validationOptions?: ValidationO...
  class MyClass (line 195) | class MyClass {
  function IsSameType (line 243) | function IsSameType(property: unknown, validationOptions?: ValidationOpt...
  class MyClass (line 263) | class MyClass {

FILE: test/functional/inherited-validation.spec.ts
  class MyClass (line 10) | class MyClass {
  class MySubClass (line 15) | class MySubClass extends MyClass {

FILE: test/functional/nested-validation.spec.ts
  class MySubClass (line 11) | class MySubClass {
  class MyClass (line 16) | class MyClass {
  class MySubClass (line 39) | class MySubClass {
  class MyClass (line 44) | class MyClass {
  class MySubClass (line 152) | class MySubClass {
  class MyClass (line 157) | class MyClass {
  class MySubClass (line 178) | class MySubClass {
  class MyClass (line 183) | class MyClass {
  class MySubClass (line 245) | class MySubClass {
  class MyClass (line 250) | class MyClass {
  class MySubClass (line 310) | class MySubClass {
  class MyClass (line 315) | class MyClass {

FILE: test/functional/promise-validation.spec.ts
  class MySubClass (line 11) | class MySubClass {
  class MyClass (line 16) | class MyClass {
  class MySubClass (line 40) | class MySubClass {
  class MyClass (line 45) | class MyClass {
  class MySubClass (line 106) | class MySubClass {
  class MyClass (line 111) | class MyClass {
  class MyClass (line 133) | class MyClass {

FILE: test/functional/reject-validation.spec.ts
  class MyClass (line 5) | class MyClass {

FILE: test/functional/sync-validation.spec.ts
  class IsShortenThanConstraint (line 11) | @ValidatorConstraint({ name: 'isShortenThan', async: true })
    method validate (line 13) | validate(value: any, args: ValidationArguments): Promise<boolean> {
  function IsLonger (line 18) | function IsLonger(property: string, validationOptions?: ValidationOption...
  class SecondClass (line 36) | class SecondClass {

FILE: test/functional/validation-error.spec.ts
  class NestedClass (line 15) | class NestedClass {
    method constructor (line 26) | constructor(url: string, name: any, insideNested?: NestedClass) {
  class RootClass (line 33) | class RootClass {
    method constructor (line 44) | constructor() {

FILE: test/functional/validation-functions-and-decorators.spec.ts
  function checkValidValues (line 204) | function checkValidValues(
  function checkInvalidValues (line 224) | function checkInvalidValues(
  function checkReturnedError (line 248) | function checkReturnedError(
  class MyClass (line 274) | class MyClass {
  class MyClass (line 331) | class MyClass {
  class MyClass (line 364) | class MyClass {
  class MyClass (line 396) | class MyClass {
  class MyClass (line 428) | class MyClass {
  class MyClass (line 461) | class MyClass {
  class MyClass (line 494) | class MyClass {
  class MyClass (line 530) | class MyClass {
  class MyClass (line 562) | class MyClass {
  class MyClass (line 580) | class MyClass {
  class MyClass (line 598) | class MyClass {
  class MyClass (line 616) | class MyClass {
  class MyClass (line 648) | class MyClass {
  class NaNTestClass (line 653) | class NaNTestClass {
  class InfinityTestClass (line 658) | class InfinityTestClass {
  class MaxDecimalPlacesTest (line 663) | class MaxDecimalPlacesTest {
  class ZeroDecimalPlacesTest (line 668) | class ZeroDecimalPlacesTest {
  class MyClass (line 732) | class MyClass {
  class MyClass (line 764) | class MyClass {
  class MyClass (line 826) | class MyClass {
  class MyClass (line 858) | class MyClass {
  type MyDefaultIndexedEnum (line 887) | enum MyDefaultIndexedEnum {
  type MyCustomIndexedEnum (line 892) | enum MyCustomIndexedEnum {
  type MyStringEnum (line 897) | enum MyStringEnum {
  class MyClassOne (line 906) | class MyClassOne {
  class MyClassTwo (line 911) | class MyClassTwo {
  class MyClassThree (line 916) | class MyClassThree {
  class MyClass (line 977) | class MyClass {
  class MyClass (line 1028) | class MyClass {
  class MyClass (line 1079) | class MyClass {
  class MyClass (line 1112) | class MyClass {
  class MyClass (line 1145) | class MyClass {
  class MyClass (line 1178) | class MyClass {
  class MyClass (line 1211) | class MyClass {
  class MyClass (line 1244) | class MyClass {
  class MyClass (line 1277) | class MyClass {
  class MyClass (line 1309) | class MyClass {
  class MyClass (line 1341) | class MyClass {
  class MyClass (line 1374) | class MyClass {
  class MyClass (line 1407) | class MyClass {
  class MyClass (line 1440) | class MyClass {
  class MyClass (line 1473) | class MyClass {
  class MyClass (line 1506) | class MyClass {
  class MyClass (line 1575) | class MyClass {
  class MyClass (line 1628) | class MyClass {
  class MyClass (line 1664) | class MyClass {
  class MyClassWithConstraint (line 1669) | class MyClassWithConstraint {
  class MyClass (line 1704) | class MyClass {
  class MyClass (line 1737) | class MyClass {
  class MyClass (line 1770) | class MyClass {
  class MyClass (line 1803) | class MyClass {
  class MyClass (line 1836) | class MyClass {
  class MyClass (line 1869) | class MyClass {
  class MyClass (line 1902) | class MyClass {
  class MyClass (line 1935) | class MyClass {
  class MyClass (line 1968) | class MyClass {
  class MyClass (line 2001) | class MyClass {
  class MyClass (line 2034) | class MyClass {
  class MyClass (line 2067) | class MyClass {
  class MyClass (line 2104) | class MyClass {
  class MyClass (line 2137) | class MyClass {
  class MyClass (line 2170) | class MyClass {
  class MyClass (line 2203) | class MyClass {
  class MyClass (line 2236) | class MyClass {
  class MyClass (line 2269) | class MyClass {
  class MyClass (line 2303) | class MyClass {
  class MyClass (line 2341) | class MyClass {
  class MyClass (line 2380) | class MyClass {
  class MyClass (line 2456) | class MyClass {
  class MyClass (line 2511) | class MyClass {
  class MyClass (line 2562) | class MyClass {
  class MyClass (line 2594) | class MyClass {
  class MyClass (line 2626) | class MyClass {
  class MyClass (line 2667) | class MyClass {
  class MyClass (line 2699) | class MyClass {
  class MyClass (line 2731) | class MyClass {
  class MyClass (line 2773) | class MyClass {
  class MyClass (line 2842) | class MyClass {
  class MyClass (line 2900) | class MyClass {
  class MyClass (line 2954) | class MyClass {
  class MyClass (line 3054) | class MyClass {
  class MyClass (line 3086) | class MyClass {
  class MyClass (line 3128) | class MyClass {
  class MyClass (line 3171) | class MyClass {
  class MyClass (line 3214) | class MyClass {
  class NullableMyClass (line 3259) | class NullableMyClass {
  class NonNullableMyClass (line 3263) | class NonNullableMyClass {
  class MyClass (line 3294) | class MyClass {
  class MyClass (line 3333) | class MyClass {
  class MyClass (line 3372) | class MyClass {
  class MyClass (line 3404) | class MyClass {
  class MyClass (line 3501) | class MyClass {
  class MyClass (line 3564) | class MyClass {
  class MyClass (line 3611) | class MyClass {
  class MyClass (line 3657) | class MyClass {
  class MyClass (line 3703) | class MyClass {
  class MyClass (line 3744) | class MyClass {
  class MyClass (line 3785) | class MyClass {
  class MyClass (line 3826) | class MyClass {
  class MyClass (line 3867) | class MyClass {
  class MyClass (line 3908) | class MyClass {
  class MyClass (line 3949) | class MyClass {
  class MyClass (line 3990) | class MyClass {
  class MyClass (line 4040) | class MyClass {
  class MyClass (line 4086) | class MyClass {
  class MyClass (line 4124) | class MyClass {
  class MyClass (line 4172) | class MyClass {
  class MyClass (line 4204) | class MyClass {
  class MyClass (line 4238) | class MyClass {
  class MyClass (line 4277) | class MyClass {
  class MyClass (line 4310) | class MyClass {
  class MyClass (line 4343) | class MyClass {
  class MyClass (line 4377) | class MyClass {
  class MyClass (line 4406) | class MyClass {
  class MyClass (line 4428) | class MyClass {
  class MyClass (line 4463) | class MyClass {
  class MyClass (line 4500) | class MyClass {
  class MyClass (line 4516) | class MyClass {
  class MyClass (line 4533) | class MyClass {
  class MyClass (line 4550) | class MyClass {
  function testHash (line 4567) | function testHash(algorithm: ValidatorJS.HashAlgorithm, validValues: any...
  class MyClass (line 4747) | class MyClass {
  class MyClass (line 4781) | class MyClass {
  class MyClass (line 4818) | class MyClass {
  class MyClass (line 4857) | class MyClass {
  class MyClass (line 4898) | class MyClass {
  class MyClass (line 4931) | class MyClass {
  class MyClass (line 4964) | class MyClass {
  class MyClass (line 5007) | class MyClass {
  class MyClass (line 5051) | class MyClass {
  class MySubClass (line 5080) | class MySubClass {
  class WrongSubClass (line 5084) | class WrongSubClass {
  class MyClass (line 5088) | class MyClass {
  class MyClass (line 5120) | class MyClass {
  class MyClass (line 5160) | class MyClass {
  class MyClass (line 5204) | class MyClass {
  class MyClass (line 5233) | class MyClass {
  class MyClass (line 5250) | class MyClass {

FILE: test/functional/validation-options.spec.ts
  class MyClass (line 29) | class MyClass {
  class MyClass (line 46) | class MyClass {
  class MyClass (line 64) | class MyClass {
  class MyClass (line 84) | class MyClass {
  class MyClass (line 100) | class MyClass {
  class MyClass (line 116) | class MyClass {
  class MyClass (line 132) | class MyClass {
  class MyClass (line 148) | class MyClass {
  class MyClass (line 164) | class MyClass {
  class MyClass (line 185) | class MyClass {
  class CustomIsNotArrayConstraint (line 204) | @ValidatorConstraint({ name: 'customIsNotArrayConstraint', async: false })
    method validate (line 206) | validate(value: any): boolean {
  class MyClass (line 211) | class MyClass {
  class CustomContainsHelloConstraint (line 226) | @ValidatorConstraint({ name: 'customContainsHelloConstraint', async: fal...
    method validate (line 228) | validate(value: any): boolean {
    method validate (line 357) | validate(value: any): boolean {
    method validate (line 508) | validate(value: any): boolean {
  class MyClass (line 233) | class MyClass {
  class CustomAsyncContainsHelloConstraint (line 252) | @ValidatorConstraint({ name: 'customAsyncContainsHelloConstraint', async...
    method validate (line 254) | validate(value: any): Promise<boolean> {
    method validate (line 389) | validate(value: any): Promise<boolean> {
    method validate (line 540) | validate(value: any): Promise<boolean> {
  class MyClass (line 260) | class MyClass {
  class CustomMixedContainsHelloConstraint (line 279) | @ValidatorConstraint({ name: 'customMixedContainsHelloConstraint', async...
    method validate (line 281) | validate(value: any): boolean | Promise<boolean> {
    method validate (line 422) | validate(value: any): boolean | Promise<boolean> {
    method validate (line 573) | validate(value: any): boolean | Promise<boolean> {
  class MyClass (line 287) | class MyClass {
  class MyClass (line 308) | class MyClass {
  class CustomIsNotSetConstraint (line 333) | @ValidatorConstraint({ name: 'customIsNotSetConstraint', async: false })
    method validate (line 335) | validate(value: any): boolean {
  class MyClass (line 340) | class MyClass {
  class CustomContainsHelloConstraint (line 355) | @ValidatorConstraint({ name: 'customContainsHelloConstraint', async: fal...
    method validate (line 228) | validate(value: any): boolean {
    method validate (line 357) | validate(value: any): boolean {
    method validate (line 508) | validate(value: any): boolean {
  class MyClass (line 362) | class MyClass {
  class CustomAsyncContainsHelloConstraint (line 387) | @ValidatorConstraint({ name: 'customAsyncContainsHelloConstraint', async...
    method validate (line 254) | validate(value: any): Promise<boolean> {
    method validate (line 389) | validate(value: any): Promise<boolean> {
    method validate (line 540) | validate(value: any): Promise<boolean> {
  class MyClass (line 395) | class MyClass {
  class CustomMixedContainsHelloConstraint (line 420) | @ValidatorConstraint({ name: 'customMixedContainsHelloConstraint', async...
    method validate (line 281) | validate(value: any): boolean | Promise<boolean> {
    method validate (line 422) | validate(value: any): boolean | Promise<boolean> {
    method validate (line 573) | validate(value: any): boolean | Promise<boolean> {
  class MyClass (line 428) | class MyClass {
  class MyClass (line 455) | class MyClass {
  class CustomIsNotMapConstraint (line 480) | @ValidatorConstraint({ name: 'customIsNotMapConstraint', async: false })
    method validate (line 482) | validate(value: any): boolean {
  class MyClass (line 487) | class MyClass {
  class CustomContainsHelloConstraint (line 506) | @ValidatorConstraint({ name: 'customContainsHelloConstraint', async: fal...
    method validate (line 228) | validate(value: any): boolean {
    method validate (line 357) | validate(value: any): boolean {
    method validate (line 508) | validate(value: any): boolean {
  class MyClass (line 513) | class MyClass {
  class CustomAsyncContainsHelloConstraint (line 538) | @ValidatorConstraint({ name: 'customAsyncContainsHelloConstraint', async...
    method validate (line 254) | validate(value: any): Promise<boolean> {
    method validate (line 389) | validate(value: any): Promise<boolean> {
    method validate (line 540) | validate(value: any): Promise<boolean> {
  class MyClass (line 546) | class MyClass {
  class CustomMixedContainsHelloConstraint (line 571) | @ValidatorConstraint({ name: 'customMixedContainsHelloConstraint', async...
    method validate (line 281) | validate(value: any): boolean | Promise<boolean> {
    method validate (line 422) | validate(value: any): boolean | Promise<boolean> {
    method validate (line 573) | validate(value: any): boolean | Promise<boolean> {
  class MyClass (line 579) | class MyClass {
  function expectTitleContains (line 606) | function expectTitleContains(error: ValidationError): void {
  function expectTextContains (line 610) | function expectTextContains(error: ValidationError): void {
  class MyClass (line 614) | class MyClass {
  class MyClass (line 793) | class MyClass {
  function expectTitleMatches (line 799) | function expectTitleMatches(error: ValidationError): void {
  class MyClass (line 905) | class MyClass {
  class MyPayload (line 975) | class MyPayload {
  class MyClass (line 1020) | class MyClass {
  class Nested (line 1068) | class Nested {
  class Root (line 1076) | class Root {
  function expectChildConstraint (line 1089) | function expectChildConstraint(error: ValidationError, childName: string...
  function IsLongerThan (line 1124) | function IsLongerThan(property: string, validationOptions?: ValidationOp...
  class MyClass (line 1147) | class MyClass {
  class MyClass (line 1194) | class MyClass {
  class MyClass (line 1219) | class MyClass {
  class MySubClass (line 1244) | class MySubClass {
  class MyClass (line 1251) | class MyClass {
  class MyClass (line 1290) | class MyClass {

FILE: test/functional/validator-options.spec.ts
  class MyClass (line 8) | class MyClass {

FILE: test/functional/whitelist-validation.spec.ts
  class MyClass (line 9) | class MyClass {
  class MyClass (line 31) | class MyClass {
  class MyPayload (line 49) | class MyPayload {
    method constructor (line 60) | constructor(nonDecorated: string) {
Condensed preview — 204 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (603K chars).
[
  {
    "path": ".eslintrc.yml",
    "chars": 1320,
    "preview": "parser: '@typescript-eslint/parser'\nplugins:\n  - '@typescript-eslint'\nparserOptions:\n  ecmaVersion: 2018\n  sourceType: m"
  },
  {
    "path": ".gitbook.yaml",
    "chars": 67,
    "preview": "root: docs\nstructure:\n  readme: README.md\n  summary: docs/README.md"
  },
  {
    "path": ".github/dependabot.yml",
    "chars": 300,
    "preview": "version: 2\nupdates:\n- package-ecosystem: npm\n  directory: \"/\"\n  schedule:\n    interval: daily\n    time: \"10:00\"\n    time"
  },
  {
    "path": ".github/semantic.yml",
    "chars": 199,
    "preview": "titleAndCommits: true\nallowMergeCommits: false\nscopes:\n  - deps\n  - deps-dev\ntypes:\n  - feat\n  - fix\n  - docs\n  - style\n"
  },
  {
    "path": ".github/workflows/auto-approve-dependabot-workflow.yml",
    "chars": 705,
    "preview": "name: Dependabot auto-merge\non:\n  pull_request_target\njobs:\n  dependabot:\n    runs-on: ubuntu-latest\n    if: github.acto"
  },
  {
    "path": ".github/workflows/continuous-deployment-workflow.yml",
    "chars": 863,
    "preview": "name: CD\non:\n  release:\n    types: [created]\njobs:\n  publish:\n    name: Publish to NPM\n    runs-on: ubuntu-latest\n    st"
  },
  {
    "path": ".github/workflows/continuous-integration-workflow.yml",
    "chars": 1498,
    "preview": "name: CI\non: [push, pull_request]\njobs:\n  checks:\n    name: Linters\n    runs-on: ubuntu-latest\n    steps:\n      - uses: "
  },
  {
    "path": ".github/workflows/lock-closed-issues-workflow.yml",
    "chars": 760,
    "preview": "name: 'Lock inactive threads'\non:\n  schedule:\n    - cron: '0 0 * * *'\njobs:\n  lock:\n    name: Lock closed issues\n    run"
  },
  {
    "path": ".gitignore",
    "chars": 646,
    "preview": "# Log files\r\nlogs\r\n*.log\r\n*.tmp\r\n*.tmp.*\r\nlog.txt\r\nnpm-debug.log*\r\n\r\n# Testing output\r\nlib-cov/**\r\ncoverage/**\r\n\r\n# Envi"
  },
  {
    "path": ".prettierrc.yml",
    "chars": 131,
    "preview": "printWidth: 120\ntabWidth: 2\nuseTabs: false\nsemi: true\nsingleQuote: true\ntrailingComma: es5\nbracketSpacing: true\narrowPar"
  },
  {
    "path": "CHANGELOG.md",
    "chars": 27285,
    "preview": "# Changelog\n\n_This changelog follows the [keep a changelog][keep-a-changelog]_ format to maintain a human readable chang"
  },
  {
    "path": "LICENSE",
    "chars": 1075,
    "preview": "\nThe MIT License\n\nCopyright (c) 2015-2020 TypeStack\n\nPermission is hereby granted, free of charge, to any person obtaini"
  },
  {
    "path": "README.md",
    "chars": 57100,
    "preview": "# class-validator\n\n![Build Status](https://github.com/typestack/class-validator/workflows/CI/badge.svg)\n[![codecov](http"
  },
  {
    "path": "codecov.yml",
    "chars": 223,
    "preview": "coverage:\n  range: 70..100\n  round: down\n  precision: 2\n  status:\n    project:\n      default:\n        threshold: 0%\n    "
  },
  {
    "path": "docs/README.md",
    "chars": 2030,
    "preview": "# Table of Contents\n\n- [Read Me](../README.md)\n- Getting Started\n  - [Installation](introduction/installation.md)\n  - [U"
  },
  {
    "path": "docs/basics/validating-objects.md",
    "chars": 1144,
    "preview": "# Validating objects\n\n```ts\nimport {\n  validate,\n  validateOrReject,\n  IsString,\n  IsInt,\n  IsDate,\n  MaxLength,\n  Min,\n"
  },
  {
    "path": "docs/introduction/installation.md",
    "chars": 485,
    "preview": "# Installation\n\nTo install the stable version:\n\n```\nnpm install --save class-validator\n```\n\n### Usage in the browser\n\nIf"
  },
  {
    "path": "jest.config.js",
    "chars": 246,
    "preview": "module.exports = {\r\n  preset: 'ts-jest',\r\n  testEnvironment: 'node',\r\n  collectCoverageFrom: ['src/**/*.ts', '!src/**/in"
  },
  {
    "path": "package.json",
    "chars": 2091,
    "preview": "{\n  \"name\": \"class-validator\",\n  \"version\": \"0.15.1\",\n  \"description\": \"Decorator-based property validation for classes."
  },
  {
    "path": "rollup.config.js",
    "chars": 573,
    "preview": "import { nodeResolve } from '@rollup/plugin-node-resolve';\nimport commonjs from '@rollup/plugin-commonjs';\nimport { ters"
  },
  {
    "path": "sample/sample1-simple-validation/Post.ts",
    "chars": 780,
    "preview": "import {\n  Contains,\n  IsInt,\n  MinLength,\n  MaxLength,\n  IsEmail,\n  IsFQDN,\n  IsDate,\n  ArrayNotEmpty,\n  ArrayMinSize,\n"
  },
  {
    "path": "sample/sample1-simple-validation/app.ts",
    "chars": 6257,
    "preview": "import { validate } from '../../src/index';\nimport { Post, PostType } from './Post';\n\n// Sample1. simple validation\n\nlet"
  },
  {
    "path": "sample/sample2-using-groups/Post.ts",
    "chars": 690,
    "preview": "import { Contains, IsInt, Length, IsEmail, IsFQDN, IsDate } from '../../src/decorator/decorators';\n\nexport class Post {\n"
  },
  {
    "path": "sample/sample2-using-groups/app.ts",
    "chars": 2624,
    "preview": "import { Validator } from '../../src/validation/Validator';\nimport { Post } from './Post';\n\nlet validator = new Validato"
  },
  {
    "path": "sample/sample3-nested-objects/Post.ts",
    "chars": 279,
    "preview": "import { Contains, IsInt, Length, IsEmail, IsFQDN, IsDate, ValidateNested } from '../../src/decorator/decorators';\nimpor"
  },
  {
    "path": "sample/sample3-nested-objects/Tag.ts",
    "chars": 203,
    "preview": "import { Contains, IsInt, Length, IsEmail, IsFQDN, IsDate } from '../../src/decorator/decorators';\n\nexport class Tag {\n "
  },
  {
    "path": "sample/sample3-nested-objects/app.ts",
    "chars": 417,
    "preview": "import { Validator } from '../../src/validation/Validator';\nimport { Post } from './Post';\nimport { Tag } from './Tag';\n"
  },
  {
    "path": "sample/sample4-custom-validator/CustomTextLength.ts",
    "chars": 345,
    "preview": "import { ValidatorConstraintInterface } from '../../src/validation/ValidatorConstraintInterface';\nimport { ValidatorCons"
  },
  {
    "path": "sample/sample4-custom-validator/Post.ts",
    "chars": 415,
    "preview": "import {\n  Contains,\n  IsInt,\n  MinLength,\n  MaxLength,\n  IsEmail,\n  IsFQDN,\n  IsDate,\n  IsNotEmpty,\n  ArrayNotEmpty,\n  "
  },
  {
    "path": "sample/sample4-custom-validator/app.ts",
    "chars": 417,
    "preview": "import { Validator } from '../../src/validation/Validator';\nimport { Post } from './Post';\n\nlet validator = new Validato"
  },
  {
    "path": "sample/sample5-schemas/Post.ts",
    "chars": 144,
    "preview": "export class Post {\n  title: string;\n  text: string;\n  rating: number;\n  email: string;\n  site: string;\n  createDate: Da"
  },
  {
    "path": "sample/sample5-schemas/app.ts",
    "chars": 5723,
    "preview": "import { validate, registerSchema } from '../../src/index';\nimport { Post } from './Post';\n\n// load schema. we load it a"
  },
  {
    "path": "sample/sample5-schemas/post.json",
    "chars": 977,
    "preview": "{\n  \"name\": \"post\",\n  \"properties\": {\n    \"title\": [{\n      \"type\": \"minLength\",\n      \"constraints\": [10]\n    },\n    {\n"
  },
  {
    "path": "sample/sample6-custom-decorator/IsLongerThan.ts",
    "chars": 1153,
    "preview": "import { registerDecorator } from '../../src/index';\nimport { ValidationOptions } from '../../src/decorator/ValidationOp"
  },
  {
    "path": "sample/sample6-custom-decorator/IsUserAlreadyExist.ts",
    "chars": 827,
    "preview": "import { registerDecorator } from '../../src/index';\nimport { ValidationOptions } from '../../src/decorator/ValidationOp"
  },
  {
    "path": "sample/sample6-custom-decorator/User.ts",
    "chars": 352,
    "preview": "import { IsUserAlreadyExist } from './IsUserAlreadyExist';\nimport { IsLongerThan } from './IsLongerThan';\n\nexport class "
  },
  {
    "path": "sample/sample6-custom-decorator/app.ts",
    "chars": 997,
    "preview": "import { Validator } from '../../src/validation/Validator';\nimport { User } from './User';\n\nlet validator = new Validato"
  },
  {
    "path": "sample/sample7-inheritance-support/BaseContent.ts",
    "chars": 118,
    "preview": "import { IsEmail } from '../../src/decorator/decorators';\n\nexport class BaseContent {\n  @IsEmail()\n  email: string;\n}\n"
  },
  {
    "path": "sample/sample7-inheritance-support/Post.ts",
    "chars": 295,
    "preview": "import { Contains, IsInt, MinLength, MaxLength } from '../../src/decorator/decorators';\nimport { BaseContent } from './B"
  },
  {
    "path": "sample/sample7-inheritance-support/app.ts",
    "chars": 442,
    "preview": "import { validate } from '../../src/index';\nimport { Post } from './Post';\n\n// Sample1. simple validation\n\nlet post1 = n"
  },
  {
    "path": "sample/sample8-es6-maps/Post.ts",
    "chars": 290,
    "preview": "import { Contains, IsInt, Length, IsEmail, IsFQDN, IsDate, ValidateNested } from '../../src/decorator/decorators';\nimpor"
  },
  {
    "path": "sample/sample8-es6-maps/Tag.ts",
    "chars": 210,
    "preview": "import { Contains, IsInt, Length, IsEmail, IsFQDN, IsDate } from '../../src/decorator/decorators';\n\nexport class Tag {\n "
  },
  {
    "path": "sample/sample8-es6-maps/app.ts",
    "chars": 476,
    "preview": "import { Validator } from '../../src/validation/Validator';\nimport { Post } from './Post';\nimport { Tag } from './Tag';\n"
  },
  {
    "path": "sample/sample9-es6-sets/Post.ts",
    "chars": 282,
    "preview": "import { Contains, IsInt, Length, IsEmail, IsFQDN, IsDate, ValidateNested } from '../../src/decorator/decorators';\nimpor"
  },
  {
    "path": "sample/sample9-es6-sets/Tag.ts",
    "chars": 210,
    "preview": "import { Contains, IsInt, Length, IsEmail, IsFQDN, IsDate } from '../../src/decorator/decorators';\n\nexport class Tag {\n "
  },
  {
    "path": "sample/sample9-es6-sets/app.ts",
    "chars": 460,
    "preview": "import { Validator } from '../../src/validation/Validator';\nimport { Post } from './Post';\nimport { Tag } from './Tag';\n"
  },
  {
    "path": "src/container.ts",
    "chars": 1917,
    "preview": "/**\n * Container options.\n */\nexport interface UseContainerOptions {\n  /**\n   * If set to true, then default container w"
  },
  {
    "path": "src/decorator/ValidationOptions.ts",
    "chars": 1199,
    "preview": "import { ValidationArguments } from '../validation/ValidationArguments';\n\n/**\n * Options used to pass to validation deco"
  },
  {
    "path": "src/decorator/array/ArrayContains.ts",
    "chars": 1145,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/array/ArrayMaxSize.ts",
    "chars": 1104,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/array/ArrayMinSize.ts",
    "chars": 1116,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/array/ArrayNotContains.ts",
    "chars": 1151,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/array/ArrayNotEmpty.ts",
    "chars": 905,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/array/ArrayUnique.ts",
    "chars": 1566,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/common/Allow.ts",
    "chars": 881,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { ValidationMetadataArgs } from '../../metadata/Validat"
  },
  {
    "path": "src/decorator/common/Equals.ts",
    "chars": 862,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/common/IsDefined.ts",
    "chars": 945,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from './ValidateBy';\nimpor"
  },
  {
    "path": "src/decorator/common/IsEmpty.ts",
    "chars": 800,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/common/IsIn.spec.ts",
    "chars": 534,
    "preview": "import { isIn } from './IsIn';\n\ndescribe('@IsIn decorator implementation', () => {\n  describe('isIn validator', () => {\n"
  },
  {
    "path": "src/decorator/common/IsIn.ts",
    "chars": 978,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/common/IsLatLong.ts",
    "chars": 906,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from './ValidateBy';\nimpor"
  },
  {
    "path": "src/decorator/common/IsLatitude.ts",
    "chars": 878,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from './ValidateBy';\nimpor"
  },
  {
    "path": "src/decorator/common/IsLongitude.ts",
    "chars": 887,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from './ValidateBy';\nimpor"
  },
  {
    "path": "src/decorator/common/IsNotEmpty.ts",
    "chars": 834,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/common/IsNotIn.ts",
    "chars": 1008,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/common/IsOptional.ts",
    "chars": 1114,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { ValidationMetadataArgs } from '../../metadata/Validat"
  },
  {
    "path": "src/decorator/common/NotEquals.ts",
    "chars": 902,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/common/Validate.ts",
    "chars": 2258,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { ValidationMetadataArgs } from '../../metadata/Validat"
  },
  {
    "path": "src/decorator/common/ValidateBy.ts",
    "chars": 1279,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { registerDecorator } from '../../register-decorator';\n"
  },
  {
    "path": "src/decorator/common/ValidateIf.ts",
    "chars": 992,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { ValidationMetadataArgs } from '../../metadata/Validat"
  },
  {
    "path": "src/decorator/common/ValidateNested.ts",
    "chars": 1094,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { ValidationMetadataArgs } from '../../metadata/Validat"
  },
  {
    "path": "src/decorator/common/ValidatePromise.ts",
    "chars": 845,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { ValidationMetadataArgs } from '../../metadata/Validat"
  },
  {
    "path": "src/decorator/date/MaxDate.ts",
    "chars": 1009,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/date/MinDate.ts",
    "chars": 1007,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/decorators.ts",
    "chars": 5568,
    "preview": "// -------------------------------------------------------------------------\n// System\n// ------------------------------"
  },
  {
    "path": "src/decorator/number/IsDivisibleBy.ts",
    "chars": 1055,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/number/IsNegative.ts",
    "chars": 833,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/number/IsPositive.ts",
    "chars": 833,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/number/Max.ts",
    "chars": 925,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/number/Min.ts",
    "chars": 928,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/object/IsInstance.ts",
    "chars": 1296,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/object/IsNotEmptyObject.ts",
    "chars": 1442,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/Contains.ts",
    "chars": 1058,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsAlpha.ts",
    "chars": 1163,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsAlphanumeric.ts",
    "chars": 1255,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsAscii.ts",
    "chars": 984,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsBIC.ts",
    "chars": 1001,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsBase32.ts",
    "chars": 930,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsBase58.ts",
    "chars": 931,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsBase64.ts",
    "chars": 1118,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsBooleanString.ts",
    "chars": 1000,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsBtcAddress.ts",
    "chars": 980,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsByteLength.ts",
    "chars": 1225,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsCreditCard.ts",
    "chars": 970,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsCurrency.ts",
    "chars": 1158,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsDataURI.ts",
    "chars": 983,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsDateString.ts",
    "chars": 987,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsDecimal.ts",
    "chars": 1173,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsEAN.ts",
    "chars": 990,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsEmail.ts",
    "chars": 1093,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsEthereumAddress.ts",
    "chars": 1171,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsFQDN.ts",
    "chars": 1195,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsFirebasePushId.ts",
    "chars": 1045,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsFullWidth.ts",
    "chars": 1032,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsHSL.ts",
    "chars": 1349,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsHalfWidth.ts",
    "chars": 1032,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsHash.ts",
    "chars": 1346,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsHexColor.ts",
    "chars": 1000,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsHexadecimal.ts",
    "chars": 1028,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsIBAN.ts",
    "chars": 1047,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsIP.ts",
    "chars": 1224,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsISBN.ts",
    "chars": 1256,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsISIN.ts",
    "chars": 1010,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsISO31661Alpha2.ts",
    "chars": 1131,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsISO31661Alpha3.ts",
    "chars": 1131,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsISO31661Numeric.ts",
    "chars": 1149,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsISO8601.ts",
    "chars": 1415,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsISRC.ts",
    "chars": 892,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsISSN.ts",
    "chars": 1070,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsIdentityCard.ts",
    "chars": 1543,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsJSON.ts",
    "chars": 956,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsJWT.ts",
    "chars": 908,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsLocale.ts",
    "chars": 913,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsLowercase.ts",
    "chars": 986,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsMacAddress.ts",
    "chars": 1709,
    "preview": "import { ValidationOptions, isValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from "
  },
  {
    "path": "src/decorator/string/IsMagnetURI.ts",
    "chars": 1005,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsMilitaryTime.ts",
    "chars": 1276,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsMimeType.ts",
    "chars": 1019,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsMobilePhone.ts",
    "chars": 3187,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsMongoId.ts",
    "chars": 1028,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsMultibyte.ts",
    "chars": 1048,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsNumberString.ts",
    "chars": 1152,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsOctal.ts",
    "chars": 970,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsPassportNumber.ts",
    "chars": 1245,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsPhoneNumber.spec.ts",
    "chars": 1617,
    "preview": "import { isPhoneNumber } from './IsPhoneNumber';\n\ndescribe('@IsPhoneNumber decorator implementation', () => {\n  describe"
  },
  {
    "path": "src/decorator/string/IsPhoneNumber.ts",
    "chars": 2203,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsPort.ts",
    "chars": 801,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsPostalCode.ts",
    "chars": 1218,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsRFC3339.ts",
    "chars": 957,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsRgbColor.ts",
    "chars": 1496,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsSemVer.ts",
    "chars": 1046,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsStrongPassword.ts",
    "chars": 1342,
    "preview": "import * as validator from 'validator';\nimport { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage,"
  },
  {
    "path": "src/decorator/string/IsSurrogatePair.ts",
    "chars": 1080,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsTimeZone.ts",
    "chars": 1225,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsUUID.ts",
    "chars": 1457,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsUppercase.ts",
    "chars": 947,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsUrl.ts",
    "chars": 1063,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/IsVariableWidth.ts",
    "chars": 1083,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/Length.ts",
    "chars": 1934,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/Matches.ts",
    "chars": 1932,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/MaxLength.ts",
    "chars": 1250,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/MinLength.ts",
    "chars": 1241,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/NotContains.ts",
    "chars": 1101,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/is-iso4217-currency-code.ts",
    "chars": 1103,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/is-tax-id.ts",
    "chars": 1597,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/string/isISO6391.ts",
    "chars": 1033,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/typechecker/IsArray.ts",
    "chars": 729,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/typechecker/IsBoolean.ts",
    "chars": 770,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/typechecker/IsDate.ts",
    "chars": 737,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/typechecker/IsEnum.ts",
    "chars": 1277,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/typechecker/IsInt.ts",
    "chars": 759,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/typechecker/IsNumber.ts",
    "chars": 1544,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/typechecker/IsObject.ts",
    "chars": 910,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/decorator/typechecker/IsString.ts",
    "chars": 768,
    "preview": "import { ValidationOptions } from '../ValidationOptions';\nimport { buildMessage, ValidateBy } from '../common/ValidateBy"
  },
  {
    "path": "src/index.ts",
    "chars": 4883,
    "preview": "import { ValidationError } from './validation/ValidationError';\nimport { ValidatorOptions } from './validation/Validator"
  },
  {
    "path": "src/metadata/ConstraintMetadata.ts",
    "chars": 1418,
    "preview": "import { ValidatorConstraintInterface } from '../validation/ValidatorConstraintInterface';\nimport { getFromContainer } f"
  },
  {
    "path": "src/metadata/MetadataStorage.ts",
    "chars": 6310,
    "preview": "import { ValidationMetadata } from './ValidationMetadata';\nimport { ConstraintMetadata } from './ConstraintMetadata';\nim"
  },
  {
    "path": "src/metadata/ValidationMetadata.ts",
    "chars": 2559,
    "preview": "import { ValidationMetadataArgs } from './ValidationMetadataArgs';\nimport { ValidationArguments } from '../validation/Va"
  },
  {
    "path": "src/metadata/ValidationMetadataArgs.ts",
    "chars": 819,
    "preview": "import { ValidationOptions } from '../decorator/ValidationOptions';\n\n/**\n * Constructor arguments for ValidationMetadata"
  },
  {
    "path": "src/register-decorator.ts",
    "chars": 2960,
    "preview": "import { ConstraintMetadata } from './metadata/ConstraintMetadata';\nimport { ValidatorConstraintInterface } from './vali"
  },
  {
    "path": "src/utils/convert-to-array.util.ts",
    "chars": 245,
    "preview": "/**\n * Convert Map, Set to Array\n */\nexport function convertToArray<T>(val: Array<T> | Set<T> | Map<any, T>): Array<T> {"
  },
  {
    "path": "src/utils/get-global.util.ts",
    "chars": 960,
    "preview": "/**\n * This function returns the global object across Node and browsers.\n *\n * Note: `globalThis` is the standardized ap"
  },
  {
    "path": "src/utils/index.ts",
    "chars": 111,
    "preview": "export * from './convert-to-array.util';\nexport * from './get-global.util';\nexport * from './is-promise.util';\n"
  },
  {
    "path": "src/utils/is-promise.util.ts",
    "chars": 248,
    "preview": "// https://github.com/TylorS/typed-is-promise/blob/abf1514e1b6961adfc75765476b0debb96b2c3ae/src/index.ts\n\nexport functio"
  },
  {
    "path": "src/validation/ValidationArguments.ts",
    "chars": 648,
    "preview": "/**\n * Arguments being sent to message builders - user can create message either by simply returning a string,\n * either"
  },
  {
    "path": "src/validation/ValidationError.ts",
    "chars": 2932,
    "preview": "/**\n * Validation error description.\n */\nexport class ValidationError {\n  /**\n   * Object that was validated.\n   *\n   * "
  },
  {
    "path": "src/validation/ValidationExecutor.ts",
    "chars": 17602,
    "preview": "import { Validator } from './Validator';\nimport { ValidationError } from './ValidationError';\nimport { ValidationMetadat"
  },
  {
    "path": "src/validation/ValidationTypes.ts",
    "chars": 685,
    "preview": "/**\n * Validation types.\n */\nexport class ValidationTypes {\n  /* system */\n  static CUSTOM_VALIDATION = 'customValidatio"
  },
  {
    "path": "src/validation/ValidationUtils.ts",
    "chars": 1688,
    "preview": "import { ValidationArguments } from './ValidationArguments';\n\n/**\n * Convert the constraint to a string to be shown in a"
  },
  {
    "path": "src/validation/Validator.ts",
    "chars": 4748,
    "preview": "import { ValidationError } from './ValidationError';\nimport { ValidatorOptions } from './ValidatorOptions';\nimport { Val"
  },
  {
    "path": "src/validation/ValidatorConstraintInterface.ts",
    "chars": 536,
    "preview": "import { ValidationArguments } from './ValidationArguments';\n/**\n * Custom validators must implement this interface to p"
  },
  {
    "path": "src/validation/ValidatorOptions.ts",
    "chars": 2639,
    "preview": "/**\n * Options passed to validator during validation.\n */\nexport interface ValidatorOptions {\n  /**\n   * If set to true "
  },
  {
    "path": "src/validation-schema/ValidationSchema.ts",
    "chars": 1844,
    "preview": "/**\n * Validation schema is a decorator-free way of validation of your objects.\n * Also using validation schemas makes t"
  },
  {
    "path": "src/validation-schema/ValidationSchemaToMetadataTransformer.ts",
    "chars": 1270,
    "preview": "import { ValidationSchema } from './ValidationSchema';\nimport { ValidationMetadata } from '../metadata/ValidationMetadat"
  },
  {
    "path": "test/functional/conditional-validation.spec.ts",
    "chars": 2723,
    "preview": "import { IsNotEmpty, ValidateIf, IsOptional, Equals } from '../../src/decorator/decorators';\nimport { Validator } from '"
  },
  {
    "path": "test/functional/custom-decorators.spec.ts",
    "chars": 9636,
    "preview": "import { Validator } from '../../src/validation/Validator';\nimport { ValidationArguments } from '../../src/validation/Va"
  },
  {
    "path": "test/functional/inherited-validation.spec.ts",
    "chars": 1247,
    "preview": "import { Contains, MinLength } from '../../src/decorator/decorators';\nimport { Validator } from '../../src/validation/Va"
  },
  {
    "path": "test/functional/nested-validation.spec.ts",
    "chars": 12390,
    "preview": "import { Contains, IsDefined, MinLength, ValidateNested } from '../../src/decorator/decorators';\nimport { Validator } fr"
  },
  {
    "path": "test/functional/promise-validation.spec.ts",
    "chars": 5157,
    "preview": "import { Contains, IsDefined, MinLength, ValidateNested, ValidatePromise } from '../../src/decorator/decorators';\nimport"
  },
  {
    "path": "test/functional/reject-validation.spec.ts",
    "chars": 1148,
    "preview": "import { ValidationError } from './../../src/validation/ValidationError';\nimport { Contains } from '../../src/decorator/"
  },
  {
    "path": "test/functional/sync-validation.spec.ts",
    "chars": 2492,
    "preview": "import { Validator } from '../../src/validation/Validator';\nimport { ValidationArguments } from '../../src/validation/Va"
  },
  {
    "path": "test/functional/validation-error.spec.ts",
    "chars": 4148,
    "preview": "import { IsString, IsUrl, IsOptional, ValidateNested, MinLength } from '../../src/decorator/decorators';\nimport { Valida"
  },
  {
    "path": "test/functional/validation-functions-and-decorators.spec.ts",
    "chars": 162534,
    "preview": "import {\n  IsBooleanString,\n  IsPositive,\n  IsLatLong,\n  IsLongitude,\n  IsLatitude,\n  IsNegative,\n  Contains,\n  Equals,\n"
  },
  {
    "path": "test/functional/validation-options.spec.ts",
    "chars": 45147,
    "preview": "import {\n  Contains,\n  Equals,\n  IsDefined,\n  Matches,\n  Max,\n  MinLength,\n  IsArray,\n  Validate,\n  ValidateNested,\n  Va"
  },
  {
    "path": "test/functional/validator-options.spec.ts",
    "chars": 3776,
    "preview": "import { IsNotEmpty } from '../../src/decorator/decorators';\nimport { Validator } from '../../src/validation/Validator';"
  },
  {
    "path": "test/functional/whitelist-validation.spec.ts",
    "chars": 2329,
    "preview": "import { Allow, IsDefined, IsOptional, Min } from '../../src/decorator/decorators';\nimport { Validator } from '../../src"
  },
  {
    "path": "test/utils.spec.ts",
    "chars": 1029,
    "preview": "import { convertToArray } from '../src/utils';\n\ndescribe('convertToArray', () => {\n  it('convert Set into array', () => "
  },
  {
    "path": "tsconfig.json",
    "chars": 528,
    "preview": "{\r\n  \"compilerOptions\": {\r\n    \"module\": \"commonjs\",\r\n    \"moduleResolution\": \"node\",\r\n    \"target\": \"es2018\",\r\n    \"lib"
  },
  {
    "path": "tsconfig.prod.cjs.json",
    "chars": 121,
    "preview": "{\n  \"extends\": \"./tsconfig.prod.json\",\n  \"compilerOptions\": {\n    \"module\": \"CommonJS\",\n    \"outDir\": \"build/cjs\"\n  },\n}"
  },
  {
    "path": "tsconfig.prod.esm2015.json",
    "chars": 124,
    "preview": "{\n  \"extends\": \"./tsconfig.prod.json\",\n  \"compilerOptions\": {\n    \"module\": \"ES2015\",\n    \"outDir\": \"build/esm2015\",\n  }"
  }
]

// ... and 4 more files (download for full content)

About this extraction

This page contains the full source code of the typestack/class-validator GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 204 files (559.7 KB), approximately 140.8k tokens, and a symbol index with 675 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!