How to use the class-validator.Min function in class-validator

To help you get started, we’ve selected a few class-validator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nestjs / graphql / tests / type-graphql / recipes / dto / recipes.args.ts View on Github external
import { Max, Min } from 'class-validator';
import { ArgsType, Field, Int } from 'type-graphql';

@ArgsType()
export class RecipesArgs {
  @Field(type => Int)
  @Min(0)
  skip: number = 0;

  @Field(type => Int)
  @Min(1)
  @Max(50)
  take: number = 25;
}
github nestjs / graphql / tests / type-graphql / recipes / dto / recipes.args.ts View on Github external
import { Max, Min } from 'class-validator';
import { ArgsType, Field, Int } from 'type-graphql';

@ArgsType()
export class RecipesArgs {
  @Field(type => Int)
  @Min(0)
  skip: number = 0;

  @Field(type => Int)
  @Min(1)
  @Max(50)
  take: number = 25;
}
github danielwii / asuna-node-server / src / modules / core / uploader / controller.ts View on Github external
@IsNumber()
  @Min(1)
  totalChunks: number;
}

class CreateChunksUploadTaskQuery {
  @IsString()
  @Transform(value => _.trim(value))
  readonly key: string;

  @IsString()
  @Transform(value => _.trim(value))
  readonly filename: string;

  @IsNumber()
  @Min(1)
  @IsOptional()
  @Transform(value => Number(value))
  readonly totalChunks: number = 1;
}

@ApiTags('core')
@Controller('api/v1/uploader')
export class UploaderController {
  private context = AsunaContext.instance;

  constructor(private readonly uploaderService: UploaderService) {}

  /**
   * 创建 chunk 上传任务
   * @param query
   * @param req
github MichalLytek / type-graphql / examples / middlewares-custom-decorators / recipe / recipe.args.ts View on Github external
import { IsPositive, Max, Min } from "class-validator";
import { ArgsType, Field, Int } from "../../../src";

@ArgsType()
export class RecipesArgs {
  @Field(type => Int)
  @Min(0)
  skip: number = 0;

  @Field(type => Int)
  @Min(1)
  @Max(50)
  take: number = 10;
}
github xmlking / ngx-starter-kit / apps / api / src / app / core / crud / pagination-params.ts View on Github external
*/
export abstract class PaginationParams {
  /**
   * Pagination limit
   */
  @IsOptional()
  @Min(0)
  @Max(50)
  @Transform((val: string) => parseInt(val, 10))
  readonly take ? = 10;

  /**
   * Pagination offset
   */
  @IsOptional()
  @Min(0)
  @Transform((val: string) => parseInt(val, 10))
  readonly skip ? = 0;

  /**
   * OrderBy
   */
  @IsOptional()
  abstract readonly order?: { [P in keyof T]?: OrderType };
}
github NarHakobyan / awesome-nest-boilerplate / src / common / dto / PageOptionsDto.ts View on Github external
default: 1,
    })
    @Type(() => Number)
    @IsInt()
    @Min(1)
    @IsOptional()
    readonly page: number = 1;

    @ApiModelPropertyOptional({
        minimum: 1,
        maximum: 50,
        default: 10,
    })
    @Type(() => Number)
    @IsInt()
    @Min(10)
    @Max(50)
    @IsOptional()
    readonly take: number = 10;

    get skip(): number {
        return (this.page - 1) * this.take;
    }

    @ApiModelPropertyOptional()
    @IsString()
    @IsNotEmpty()
    @IsOptional()
    readonly q?: string;
}
github goparrot / geocoder / src / model / query.ts View on Github external
export class Query implements QueryInterface {
    static readonly DEFAULT_RESULT_LIMIT: number = 5;
    static readonly DEFAULT_RESULT_LANGUAGE: string = 'en';

    @IsOptional()
    @IsEnum(AccuracyEnum)
    accuracy?: AccuracyEnum;

    @IsOptional()
    @IsString()
    @MinLength(2)
    @MaxLength(2)
    countryCode?: string;

    @IsNumber()
    @Min(1)
    @Max(100)
    limit: number = Query.DEFAULT_RESULT_LIMIT;

    @IsString()
    @MinLength(2)
    @MaxLength(2)
    language: string = Query.DEFAULT_RESULT_LANGUAGE;

    @ToBoolean()
    @IsBoolean()
    fillMissingQueryProperties: boolean = true;

    @ToBoolean()
    @IsBoolean()
    withRaw: boolean = false;
}
github magishift / magishift.core / src / crud / crud.filter.ts View on Github external
@ApiModelProperty()
  order?: string[];

  @Field(() => Int, { nullable: true })
  @ApiModelProperty()
  @IsOptional()
  @IsInt()
  @Min(1)
  @Max(1000)
  limit?: number;

  @Field(() => Int, { nullable: true })
  @ApiModelProperty()
  @IsOptional()
  @IsInt()
  @Min(0)
  offset?: number;

  @IsOptional()
  @IsBoolean()
  @Field({ nullable: true })
  @ApiModelProperty()
  isShowDeleted?: boolean;

  @IsOptional()
  @IsBoolean()
  @Field(() => [String], { nullable: true })
  @ApiModelProperty()
  relations?: string[];

  constructor(partial: Partial>) {
    Object.assign(this, partial);
github magishift / magishift.core / packages / crud / src / magi.filter.ts View on Github external
import { IMagiDto } from './interfaces/magi.interface';

export abstract class MagiFilter implements IFilter {
  abstract where: Partial;

  abstract whereOr: Partial;

  @IsOptional()
  @IsArray()
  @ApiModelProperty({ required: false, type: String, description: '["id ASC"]' })
  order?: string[];

  @ApiModelProperty({ required: false })
  @IsOptional()
  @IsInt()
  @Min(1)
  @Max(1000)
  limit?: number;

  @ApiModelProperty({ required: false })
  @IsOptional()
  @IsInt()
  @Min(0)
  offset?: number;

  @IsOptional()
  @IsBoolean()
  @ApiModelProperty({ required: false, type: String, description: '["relationA", "relationB"]' })
  relations?: string[];

  isShowDeleted?: boolean;
github NarHakobyan / awesome-nest-boilerplate / src / common / dto / PageOptionsDto.ts View on Github external
export class PageOptionsDto {
    @ApiModelPropertyOptional({
        enum: Order,
        default: Order.ASC,
    })
    @IsEnum(Order)
    @IsOptional()
    readonly order: Order = Order.ASC;

    @ApiModelPropertyOptional({
        minimum: 1,
        default: 1,
    })
    @Type(() => Number)
    @IsInt()
    @Min(1)
    @IsOptional()
    readonly page: number = 1;

    @ApiModelPropertyOptional({
        minimum: 1,
        maximum: 50,
        default: 10,
    })
    @Type(() => Number)
    @IsInt()
    @Min(10)
    @Max(50)
    @IsOptional()
    readonly take: number = 10;

    get skip(): number {