class-validator-extended

April 15, 2026 ยท View on GitHub

No Maintenance Intended Typescript npm GitHub Workflow Status GitHub Issues libraries.io Codecov npm bundle size

class-validator-extended

Additional validators for class-validator.

Safe and simple to use

Installation

Use your favorite package manager to install:

npm install class-validator-extended

For obvious reasons, class-validator needs to be installed.

Usage

Just use the decorators like any of the built-in ones:

import { ArrayMinSize } from 'class-validator'
import { ArrayMonotonic } from 'class-validator-extended'

class Foo {
    @ArrayMinSize(2)
    @ArrayMonotonic()
    values: [1, 13, 42]
}

If you don't have Dayjs installed you need to use the minimal export:

import { MaxBigInt } from 'class-validator-extended/dist/minimal'

Please note that Dayjs is an optional dependency and will by default be installed by npm and yarn. To avoid this use npm install --omit optional or yarn install --ignore-optional, respectively.

Validation decorators

For detailed information please read the API docs.

DecoratorDescriptionAPI
Type
@IsBigInt(options?)Checks if the given value is a BigInt.๐Ÿ”—
@IsDayjs(options?)Checks if the given value is a valid Dayjs object.๐Ÿ”—
@IsDuration(options?)Checks if the given value is a valid Dayjs duration.๐Ÿ”—
@IsNull(options?)Checks if the given value is null.๐Ÿ”—
@IsMap(options?)Checks if the given value is a Map.๐Ÿ”—
@IsSet(options?)Checks if the given value is a Set.๐Ÿ”—
Common
@Nullable(options?)Only validates the given value if it is not null.๐Ÿ”—
@Optional(options?)Only validates the given value if it is not undefined.๐Ÿ”—
Array
@ArrayMonotonic(options?)Checks if the given value is an array sorted in either (strictly) ascending or (strictly) descending order.๐Ÿ”—
@ArraySize(size, options?)Checks if the given value is an array with exactly size elements.๐Ÿ”—
BigInt
@MaxBigInt(maximum, options?)Checks if the given value is a BigInt not greater than maximum.๐Ÿ”—
@MinBigInt(minimum, options?)Checks if the given value is a BigInt not less than minimum.๐Ÿ”—
@NegativeBigInt(options?)Checks if the given value is a BigInt less than zero.๐Ÿ”—
@PositiveBigInt(options?)Checks if the given value is a BigInt greater than zero.๐Ÿ”—
Date
@FutureDate(options?)Checks if the given value is a Date object in the future.๐Ÿ”—
@PastDate(options?)Checks if the given value is a Date object in the past.๐Ÿ”—
Dayjs
@FutureDayjs(options?)Checks if the given value is a valid Dayjs object in the future.๐Ÿ”—
@MaxDayjs(maximum, options?)Checks if the given value is a valid Dayjs object not later than maximum.๐Ÿ”—
@MaxDuration(minimum, options?)Checks if the given value is a valid Dayjs duration not longer than maximum.๐Ÿ”—
@MinDayjs(minimum, options?)Checks if the given value is a valid Dayjs object not earlier than minimum.๐Ÿ”—
@MinDuration(minimum, options?)Checks if the given value is a valid Dayjs duration not shorter than minimum.๐Ÿ”—
@PastDayjs(options?)Checks if the given value is a valid Dayjs object in the past.๐Ÿ”—
Map
@MapContains(required, options?)Checks if the given value is a Map and contains all required values.๐Ÿ”—
@MapContainsKeys(required, options?)Checks if the given value is a Map and contains all required keys.๐Ÿ”—
@MapMaxSize(maximum, options?)Checks if the given value is a Map with no more than maximum entries.๐Ÿ”—
@MapMinSize(minimum, options?)Checks if the given value is a Map with no fewer than minimum entries.๐Ÿ”—
@MapNotContains(forbidden, options?)Checks if the given value is a Map which does not contain any of the forbidden values.๐Ÿ”—
@MapNotContainsKeys(forbidden, options?)Checks if the given value is a Map which does not contain any of the forbidden keys.๐Ÿ”—
@MapNotEmpty(options?)Checks if the given value is a Map with at least one entry.๐Ÿ”—
@MapSize(size, options?)Checks if the given value is a Map with exactly size entries.๐Ÿ”—
@MapUnique(projection, options?)Checks if the given value is a Map without duplicates with regard to the given projection.๐Ÿ”—
@MapUniqueKeys(projection, options?)Checks if the given value is a Map whose keys are all unique with regard to the given projection.๐Ÿ”—
Number
@IsNetworkPort(options?)Checks if the given value is a valid port number.๐Ÿ”—
Set
@SetContains(required, options?)Checks if the given value is a Set and contains all required values.๐Ÿ”—
@SetMaxSize(maximum, options?)Checks if the given value is a Set with no more than maximum values.๐Ÿ”—
@SetMinSize(minimum, options?)Checks if the given value is a Set with no fewer than minimum values.๐Ÿ”—
@SetNotContains(forbidden, options?)Checks if the given value is a Set which does not contain any of the forbidden values.๐Ÿ”—
@SetSize(size, options?)Checks if the given value is a Set with exactly size entries.๐Ÿ”—
@SetNotEmpty(options?)Checks if the given value is a Set with at least one value.๐Ÿ”—
@SetUnique(projection, options?)Checks if the given value is a Set without duplicate values with regard to the given projection.๐Ÿ”—
String
@IsAwsRegion(options?)Checks if the given value is an AWS region string. deprecated๐Ÿ”—
@IsAwsARN(options?)Checks if the given value is an AWS ARN string. deprecated๐Ÿ”—
@NotMatches(pattern, modifiers?, options?)Checks if the given value is an string that does not match the given regular expression.๐Ÿ”—