npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

class-validator-extended

v4.0.1

Published

Additional validators for class-validator.

Downloads

20,763

Readme

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.

| 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. | 🔗 | | @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. | 🔗 | | @IsAwsARN(options?) | Checks if the given value is an AWS ARN string. | 🔗 | | @NotMatches(pattern, modifiers?, options?) | Checks if the given value is an string that does not match the given regular expression. | 🔗 |