| Decorator | Type | Description| | --- | --- | --- | | @IsNullableString | string | null | If want to ignore value ≠= ‘’, @IsNullableString({ blank: true }) | | @IsUndefinableString | string | undefined | If want to ignore value ≠= ‘’, @IsUn
npm install custom-class-validator-tools
| Decorator | Type | Description|
| --- | --- | --- |
| @IsNullableString | string | null | If want to ignore value ≠= ‘’, @IsNullableString({ blank: true }) |
| @IsUndefinableString | string | undefined | If want to ignore value ≠= ‘’, @IsUndefinableString({ blank: true }) |
| @IsOptionalString | string | null | undefined | If want to ignore value ≠= ‘’, @IsOptionalString({ blank: true }) |
| @IsNotEmptyNumberString | string | Checks a string is a number |
| @IsNotEmptyBooleanString | string | Checks a string is a boolean |
| @IsNullableNumberString | string | null | Checks a string is a number or null |
| @IsNullableBooleanString | string | null | Checks a string is a boolean or null |
| @IsUndefinableNumberString | string | undefined | Checks a string is a number or undefined |
| @IsUndefinableBooleanString | string | undefined | Checks a string is a boolean or null |
| @IsOptionalNumberString | string | null | undefined | Checks a string is a number or null or undefined |
| @IsOptionalBooleanString | string | null | undefined | Checks a string is a boolean or null or undefined |
| Decorator | Type |
|----------------------|--------|
| @IsNotEmptyNumber | number |
| @IsNullableNumber | nubmer | null |
| @IsUndefinableNumber | number | undefined |
| @IsOptionalNumber | number | null | undefined |
| | |
| Decorator | Type |
| --- | --- |
| @IsNotEmptyBoolean | boolean |
| @IsNullableBoolean | boolean | null |
| @IsUndefinalbeBoolean | boolean | undefined |
| @IsOptionalBoolean | boolean | null | undefined |
``ts
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;
}
``