custom-class-validator-tools
TypeScript icon, indicating that this package has built-in type declarations

1.1.20 • Public • Published

String type decorator

Decorator Type Description
@IsNullableString string null
@IsUndefinableString string undefined
@IsOptionalString string null
@IsNotEmptyNumberString string Checks a string is a number
@IsNotEmptyBooleanString string Checks a string is a boolean
@IsNullableNumberString string null
@IsNullableBooleanString string null
@IsUndefinableNumberString string undefined
@IsUndefinableBooleanString string undefined
@IsOptionalNumberString string null
@IsOptionalBooleanString string null

Number type decorator

Decorator Type
@IsNotEmptyNumber number
@IsNullableNumber nubmer
@IsUndefinableNumber number
@IsOptionalNumber number

Boolean type decorator

Decorator Type
@IsNotEmptyBoolean boolean
@IsNullableBoolean boolean
@IsUndefinalbeBoolean boolean
@IsOptionalBoolean boolean

ValidateNested usage case

import { isNotEmptyString, IsNotEmptyBoolean, isNullable, IsUndefinable } from 'custom-class-validator-tools';
import { IsInstance, ArrayNotEmpty, ValidateNested } from 'class-validator';
import { Type } from 'class-transformer';

class Tag {
  @IsNotEmptyString()
  tag1: string;
  @IsNotEmptyString()
  tag2: string;
}

class Result {
  @IsNotEmptyBoolean()
  failed: boolean;
}

class Post {
  @IsNullable()
  @ArrayNotEmpty()
  @IsInstance(Tag, { each: true })
  @ValidateNested({ each: true })
  @Type(() => Tag)
  tags: Tag[] | null;

  @IsUndefinable()
  @IsInstance(Result)
  @ValidateNested()
  @Type(() => Result)
  result?: Result;
}

Readme

Keywords

none

Package Sidebar

Install

npm i custom-class-validator-tools

Weekly Downloads

327

Version

1.1.20

License

MIT

Unpacked Size

104 kB

Total Files

112

Last publish

Collaborators

  • internalservererror
  • obtamanyikibwa