Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
class-validator-extended
Advanced tools
Additional decorator and non-decorator based validation for class-validator.
Additional decorator and non-decorator based validation for class-validator.
Use your favorite package manager to install:
npm install class-validator-extended
For obvious reasons, class-validator needs to be installed.
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.
For detailed information please read the API docs.
Decorator | Description | API |
---|---|---|
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. | 🔗 |
@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. | 🔗 |
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. | 🔗 |
@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. | 🔗 |
@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. | 🔗 |
@IsAwsARN(options?) | Checks if the given value is an AWS ARN string. | 🔗 |
@IsTimezone(options?) | Checks if the given value is a valid timezone string. | 🔗 |
[1.0.0] - 2022-04-03
FAQs
Additional validators for class-validator.
The npm package class-validator-extended receives a total of 2,678 weekly downloads. As such, class-validator-extended popularity was classified as popular.
We found that class-validator-extended demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.