mirror of
https://github.com/Kevsl/crypto-exchange-api.git
synced 2025-07-08 21:50:13 +02:00
added more security check rules in dtos
This commit is contained in:
parent
1171e5e13c
commit
0ba8b52be3
@ -1,11 +1,20 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsEmail, IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
||||
import {
|
||||
IsEmail,
|
||||
IsNotEmpty,
|
||||
IsOptional,
|
||||
IsString,
|
||||
MaxLength,
|
||||
MinLength,
|
||||
} from 'class-validator';
|
||||
export class AuthRegisterDto {
|
||||
@ApiProperty({
|
||||
type: String,
|
||||
description: 'FirstName',
|
||||
example: 'Thomas',
|
||||
})
|
||||
@MinLength(1)
|
||||
@MaxLength(50)
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
firstName: string;
|
||||
@ -15,6 +24,8 @@ export class AuthRegisterDto {
|
||||
description: 'Last Name',
|
||||
example: 'Anderson',
|
||||
})
|
||||
@MinLength(1)
|
||||
@MaxLength(50)
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
lastName: string;
|
||||
@ -24,6 +35,8 @@ export class AuthRegisterDto {
|
||||
description: 'Pseudo',
|
||||
example: 'Néo',
|
||||
})
|
||||
@MinLength(1)
|
||||
@MaxLength(50)
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
pseudo: string;
|
||||
@ -33,6 +46,8 @@ export class AuthRegisterDto {
|
||||
description: 'User city',
|
||||
example: 'Aix les bains',
|
||||
})
|
||||
@MinLength(1)
|
||||
@MaxLength(70)
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
city: string;
|
||||
@ -42,6 +57,7 @@ export class AuthRegisterDto {
|
||||
description: 'email',
|
||||
example: 'neo@matrix.fr',
|
||||
})
|
||||
@MaxLength(255)
|
||||
@IsEmail()
|
||||
@IsNotEmpty()
|
||||
email: string;
|
||||
|
@ -1,12 +1,23 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsNumber, IsString } from 'class-validator';
|
||||
import {
|
||||
IsNumber,
|
||||
IsString,
|
||||
IsUUID,
|
||||
Max,
|
||||
MaxLength,
|
||||
Min,
|
||||
MinLength,
|
||||
} from 'class-validator';
|
||||
export class BuyCryptoDto {
|
||||
@ApiProperty({
|
||||
type: String,
|
||||
description: 'Cryptocurrency UUID',
|
||||
example: '12121-DSZD-E221212-2121221',
|
||||
})
|
||||
@MinLength(1)
|
||||
@MaxLength(50)
|
||||
@IsString()
|
||||
@IsUUID()
|
||||
id_crypto: string;
|
||||
|
||||
@ApiProperty({
|
||||
@ -14,6 +25,8 @@ export class BuyCryptoDto {
|
||||
description: 'Amount of token traded',
|
||||
example: 2,
|
||||
})
|
||||
@Min(1)
|
||||
@Max(1000)
|
||||
@IsNumber()
|
||||
amount: number;
|
||||
}
|
||||
|
@ -1,11 +1,22 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsNumber, IsString, IsUrl } from 'class-validator';
|
||||
import {
|
||||
IsNumber,
|
||||
IsPositive,
|
||||
IsString,
|
||||
IsUrl,
|
||||
Max,
|
||||
MaxLength,
|
||||
Min,
|
||||
MinLength,
|
||||
} from 'class-validator';
|
||||
export class CryptoDto {
|
||||
@ApiProperty({
|
||||
type: String,
|
||||
description: 'Cryptocurrency name',
|
||||
example: 'BTC',
|
||||
})
|
||||
@MaxLength(50)
|
||||
@MinLength(1)
|
||||
@IsString()
|
||||
name: string;
|
||||
|
||||
@ -14,6 +25,9 @@ export class CryptoDto {
|
||||
description: 'Value for the cryptocurrency in $',
|
||||
example: 1,
|
||||
})
|
||||
@Min(1)
|
||||
@Max(10000)
|
||||
@IsPositive()
|
||||
@IsNumber()
|
||||
value: number;
|
||||
|
||||
@ -22,6 +36,9 @@ export class CryptoDto {
|
||||
description: 'Quantity of tokens available on the platform',
|
||||
example: 100,
|
||||
})
|
||||
@Min(1)
|
||||
@Max(10000)
|
||||
@IsPositive()
|
||||
@IsNumber()
|
||||
quantity: number;
|
||||
|
||||
@ -30,6 +47,7 @@ export class CryptoDto {
|
||||
description: 'Image for the cryptocurrency in ',
|
||||
example: 'https://myImage/com',
|
||||
})
|
||||
@MaxLength(255)
|
||||
@IsUrl()
|
||||
@IsString()
|
||||
image: string;
|
||||
|
@ -1,12 +1,22 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsNumber, IsPositive, IsString } from 'class-validator';
|
||||
import {
|
||||
IsNumber,
|
||||
IsPositive,
|
||||
IsString,
|
||||
IsUUID,
|
||||
Max,
|
||||
MaxLength,
|
||||
Min,
|
||||
} from 'class-validator';
|
||||
export class OfferDto {
|
||||
@ApiProperty({
|
||||
type: String,
|
||||
description: 'Cryptocurrency UUID',
|
||||
example: '12121-DSZD-E221212-2121221',
|
||||
})
|
||||
@MaxLength(50)
|
||||
@IsString()
|
||||
@IsUUID()
|
||||
id_crypto: string;
|
||||
|
||||
@ApiProperty({
|
||||
@ -15,6 +25,8 @@ export class OfferDto {
|
||||
description: 'Amount traded ',
|
||||
example: 21,
|
||||
})
|
||||
@Min(1)
|
||||
@Max(1000)
|
||||
@IsNumber()
|
||||
@IsPositive()
|
||||
amount: number;
|
||||
|
@ -1,11 +1,21 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsNumber, IsString } from 'class-validator';
|
||||
import {
|
||||
IsNumber,
|
||||
IsPositive,
|
||||
IsString,
|
||||
Max,
|
||||
MaxLength,
|
||||
Min,
|
||||
MinLength,
|
||||
} from 'class-validator';
|
||||
export class PromoCodeDto {
|
||||
@ApiProperty({
|
||||
type: String,
|
||||
description: 'Name of the PromoCOde',
|
||||
example: 'FILOU10',
|
||||
})
|
||||
@MinLength(1)
|
||||
@MaxLength(50)
|
||||
@IsString()
|
||||
name: string;
|
||||
|
||||
@ -14,6 +24,9 @@ export class PromoCodeDto {
|
||||
description: 'Dollars given for account creation when promoCode applied',
|
||||
example: 100,
|
||||
})
|
||||
@IsPositive()
|
||||
@Min(1)
|
||||
@Max(3000)
|
||||
@IsNumber()
|
||||
value: number;
|
||||
}
|
||||
|
@ -1,11 +1,13 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsString } from 'class-validator';
|
||||
import { IsString, MaxLength, MinLength } from 'class-validator';
|
||||
export class RoleDto {
|
||||
@ApiProperty({
|
||||
type: String,
|
||||
description: 'Role Name',
|
||||
example: 'user',
|
||||
})
|
||||
@MinLength(1)
|
||||
@MaxLength(50)
|
||||
@IsString()
|
||||
name: string;
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
import { IsNotEmpty, IsString, IsUUID } from 'class-validator';
|
||||
export class TradeDto {
|
||||
@ApiProperty({
|
||||
type: String,
|
||||
description: 'Offer UUID ',
|
||||
example: '121212-DSDZ1-21212DJDZ-31313',
|
||||
})
|
||||
@IsUUID()
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
id_offer: string;
|
||||
|
Loading…
x
Reference in New Issue
Block a user