Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// namespace level hard limits
export class ResourceQuota implements IResourceQuota {
@IsNotEmpty()
@ValidateNested()
@Type(() => Requests)
requests: Requests;
@IsNotEmpty()
@ValidateNested()
@Type(() => Limits)
limits: Limits;
@IsOptional()
@IsNumber()
@Min(0)
@Max(10156)
cpu ? = 1;
@IsOptional()
@IsNumber()
@Min(0)
@Max(10720)
memory ? = 1;
}
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;
}
import { Limits as ILimits } from '@ngx-starter-kit/models';
import { IsNotEmpty, IsNumber, Max, Min } from 'class-validator';
export class Limits implements ILimits {
@IsNumber()
@IsNotEmpty()
@Min(0)
@Max(10156)
cpu = 1;
@IsNumber()
@IsNotEmpty()
@Min(0)
@Max(10720)
memory = 1;
}
@IsOptional()
@IsArray()
@Field(() => [String], {
nullable: true,
description: 'ex. ["id ASC", "title DESC"]',
defaultValue: ['id ASC'],
})
@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()
import { ICreateCatDto } from '@api-interface';
import { ApiModelProperty } from '@nestjs/swagger';
import { IsInt, IsNotEmpty, Max, Min } from 'class-validator';
export class CreateCatDto implements ICreateCatDto {
@ApiModelProperty()
@IsNotEmpty()
name: string;
@ApiModelProperty()
@IsInt()
@Min(1)
@Max(200)
age: number;
}
import { Requests as IRequests } from '@ngx-starter-kit/models';
import { IsNotEmpty, IsNumber, IsOptional, Max, Min } from 'class-validator';
export class Requests implements IRequests {
@IsNumber()
@IsNotEmpty()
@Min(0)
@Max(10156)
cpu = 1;
@IsNumber()
@IsNotEmpty()
@Min(0)
@Max(10720)
memory = 1;
@IsNumber()
@IsOptional()
@Min(0)
@Max(25)
gpu: number;
}
import { Type } from 'class-transformer';
import { IsInt, IsOptional, Min, Max } from 'class-validator';
/**
* This interface represents
* options for iterating through
* paginated lists.
*/
export class PaginationOptionsDto {
/**
* The maximum amount of items to request.
*/
@IsInt()
@Min(1)
@Max(200)
@IsOptional()
@Type(() => Number)
readonly limit: number = 20;
/**
* The offset of the items
*/
@IsInt()
@Min(0)
@IsOptional()
@Type(() => Number)
readonly offset: number = 0;
}
import { Max, Min } from "class-validator";
import { ArgsType, Field, Int } from "../../src";
@ArgsType()
export class RecipesArguments {
@Field(type => Int)
@Min(0)
skip: number = 0;
@Field(type => Int)
@Min(1)
@Max(50)
take: number = 10;
}
name: 'Name',
regionNum: 'Region num'
};
id: number;
@Validate(TextLengthMore15, {
message: 'The company name must be longer than 15'
})
@IsNotEmpty()
@MaxLength(20)
name: string;
@IsOptional()
@Min(1)
@Max(99)
regionNum: number;
toString() {
const arr: string[] = [];
if (arr.length === 0 && this.name) {
arr.push(this.name);
}
return arr.join(' ');
}
constructor(data?: any) {
plainToClassFromExist(this, data);
}
}