Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
88 views

I'm researching that can I use i18n for the messages of validation exceptions. For example: create-user.dto.ts export default class createUserDto { @MinLength(5) @IsString() name: string; }...
Mehmet KÖSMEN's user avatar
0 votes
0 answers
67 views

I am having an issue with NestJs DI class-validators. In my main class I define the Validation pipe as such async function bootstrap() { const app = await NestFactory.create(AppModule, { logger: ...
Besho's user avatar
  • 33
0 votes
1 answer
91 views

Consider following Dtos: export class Child { @ApiProperty({ type: String, isArray: true, }) name: string; @ApiProperty({ type: Number, isArray: true, }) age: number; } ...
Tu Le Anh's user avatar
  • 101
2 votes
0 answers
64 views

I'm trying to receive a plain object in my DTO and to convert it into a number using a hash algorithm. I use validation pipes with whitelisting, and wanted to use the transform pipes to convert it to ...
syzztem's user avatar
  • 132
0 votes
0 answers
44 views

I am working on a NestJS project where I use class-validator to validate incoming DTOs. I have a custom validator @IsAccessPointExists() that checks if an access point exists in the database. The ...
Aslan Gurbanov's user avatar
0 votes
1 answer
74 views

I'm building an accounting application using NestJS. I have a DTO called CreateTransactionDto, and I want certain fields to be required or forbidden based on the value of transactionType. For example: ...
muratmutlu's user avatar
1 vote
1 answer
89 views

I´m trying to validate the body of a route on NestJS and i´m using the class-validator package, my route is receiving the data as multipat because this route also accepts a file upload. Here is the ...
DMinatto's user avatar
2 votes
0 answers
509 views

In a NestJS application I bave multiple DTO classes that utilize class-validator. The controller method expects POST body which can represent any of these DTOs. class A { // some validators } class B ...
user2297996's user avatar
  • 1,634
1 vote
0 answers
111 views

I am working with NestJS and trying to apply the IsEnum decorator to an optional property. However, I am encountering an error. I am using "class-validator": "^0.14.1" and my DTO ...
varsha kumari's user avatar
1 vote
1 answer
95 views

I'm trying to create an auto-check in nest js for the existence of a record in a prisma database using a validator class. I currently have the following code: interface UniqueValidatorOptions { ...
Едуард Сиволап's user avatar
1 vote
1 answer
204 views

I try to send login credentials to my NestJS API. API uses class-validator to validate incoming requests' bodies. // auth.controller.ts @Post('login') async login(@Res({ passthrough: true }) response: ...
brizgalka's user avatar
1 vote
2 answers
134 views

I working on NestJS app and trying to validate some field depending on other field. export class CreateOrderDTO { @IsDeliveryCodeValid() // Custom validator delivery_code: string; @...
Juzioikasztanka's user avatar
1 vote
0 answers
91 views

I have a POST /login route in my Express application where I'm using a payload validation middleware before the controller, structured as follows: profileRouter.post( "/login", ...
Koyejo's user avatar
  • 47
0 votes
1 answer
90 views

class RegisterBody { @IsEmail() @IsEmailRegistered() email: string; @IsStrongPassword() password: string; } I want to apply IsEmailRegistered only if IsEmail pass and always run ...
Mhmd Al-Rshedy's user avatar
2 votes
1 answer
407 views

I am building a NestJS application with a pagination API that includes filtering and searching capabilities. To handle this, I created an abstract class, PaginationAbstract, which accepts two generic ...
Saeed Ghofrani's user avatar
2 votes
1 answer
355 views

I am working on a change password endpoint using nestjs , I want to be able to validate if the two password match The class-validator library doesn't seem to have that on how to validate two ...
Ugwu Somto's user avatar
0 votes
1 answer
110 views

I use: @UsePipes(new ValidationPipe({ transform: true })) to transform query param criteria to specific types, but it doesn't work for numbers, can you explain me why? Version of @bx/nestjs-commons - ...
Paweł Grabowski's user avatar
0 votes
1 answer
113 views

Problem: Backend will receive an object, and at least one field must to be non-nullable. Example dto object: export class MessageDto implements TMessage { @IsString() @MinLength(1) roomId: ...
xNevrroXx's user avatar
  • 545
-1 votes
1 answer
293 views

I've created a controller that receives a POST/ ... request. one of the parameters is optional and it's for example called contentType. in the service i check if the contentType is equal to something ...
Yaron's user avatar
  • 143
0 votes
1 answer
64 views

In a nestjs APP, I am designing an API endpoint. While creating this endpoint I started having an issue in taking the right decision when it comes to validating incoming requests using a decent and ...
Adel Bouhraoua's user avatar
0 votes
2 answers
96 views

I am using validateIf() to check if the paymentService is equal to some enum value defined in my code. But it does not validate and throws an error . @ApiProperty({ required: true }) @...
Shehryar Tanoli's user avatar
1 vote
1 answer
358 views

I have this class class A { @IsString() @MaxLength(99) prop1: string @IsBoolean() prop2: boolean } I want it to be: string. required (if prop2 is true). optional if prop2 is false. In ...
Islam Y-'s user avatar
  • 4,140
0 votes
1 answer
139 views

I'm trying to apply a validation using class-validator to make possible that some props can be @IsOptional, but if all of them is null, throw an exception. Thinking in some approach like this: @...
Wilson de Freitas's user avatar
0 votes
1 answer
135 views

I am trying to change the behavior of the errors in NestJS. Currently when it is encountering an error, it is not just sending that error but it is still continuing the validation and displaying other ...
Bhuvana Chandra's user avatar
0 votes
1 answer
77 views

I'm writing input validation for an event handler. The payload can be either an Order object or null. I need some help on how to allow null payloads in this setup, as they are currently rejected. Here ...
thijsfranck's user avatar
0 votes
0 answers
72 views

Hello folks I am working on an University project wherein I need to manage the course taken by the students. The application has a form to add course and delete a course sometimes I observe that ...
John Wayn's user avatar
1 vote
1 answer
229 views

We generally work as, doing validation and doing all sort of validation in validator and we expect that if the request reaches controller it has already been validated againsts all the application ...
Jamal Ahmed's user avatar
0 votes
1 answer
148 views

I have a dto class-validator, example attached below. Can I remove the userId from the validation without changing the code of the dto itself. For example to do this when using dto in controller ...
Eduard Syvolap's user avatar
2 votes
0 answers
730 views

I am using tsoa with class-validator in express js Now when i define DTO with class-validator and define type for body in tsoa route, it only validates the datataype of the body object values & if ...
Dharmik soni's user avatar
0 votes
1 answer
149 views

My validation requirements for one varriable depends on the value of the other varriable. I don't know how to create my DTO properly. Look for my example: export class CreateItemDto { @IsBoolean() ...
jbundziow's user avatar
0 votes
0 answers
74 views

I have the following DTO export class UpsertSubscription { @Expose() @ValidateIf((o) => !o.monthly && !o.yearly) @IsNumber({}, { message: 'tiers.priceMustBeANumber' }) @Min(0, { ...
Omar Bahutair's user avatar
1 vote
1 answer
324 views

I wrote a dto for my endpoint, but ran into the fact that it doesn't work correctly, if one of the fields the class-validator is supposed to handle doesn't have a decorator, it stops being checked at ...
Eduard Syvolap's user avatar
2 votes
0 answers
615 views

I'm working with NestJS and using class-validator to validate data. I have an array of objects in my DTO, but I need to ensure that empty objects (objects with no properties) are eliminated from the ...
Azman Amin's user avatar
0 votes
1 answer
367 views

In NestJS, is it possible to conditionally modify the properties of a request body within controller methods based on the user’s role or access level? For instance, if a user lacks the necessary ...
MR.Mostafa's user avatar
1 vote
1 answer
139 views

I have this: import * as val from 'class-validator'; import {ObjectId as MongoId} from 'mongodb'; @val.ValidatorConstraint({async: false}) export class IsTraceValidConstraint ...
Alexander Mills's user avatar
0 votes
1 answer
885 views

I want to create a nestjs app and want to have the ability to customize the messages of class-validator, so I created a function to get keys I provide to messages and then returns the customized ...
Ako's user avatar
  • 1,611
0 votes
3 answers
6k views

I just ran into a pretty simple issue, this definition normally should have worked perfectly and pass the validation as price field in JSON is already sent in decimal format as you can figure below, ...
berk's user avatar
  • 119
2 votes
0 answers
133 views

register-user.dto.ts: export default class RegisterUserDTO { @IsNotEmpty() @IsString() firstName: string; @IsNotEmpty() @IsString() lastName: string; @IsNotEmpty() @IsString() @...
starter_dev's user avatar
0 votes
0 answers
95 views

Here is what I want to achieve. My current QueryUserDto is: import { ApiHideProperty } from '@nestjs/swagger'; import { Transform } from 'class-transformer'; import { IsEmpty, IsEnum, IsMongoId, ...
Faizan Ashiq's user avatar
0 votes
1 answer
785 views

@IsOptional() @Transform(({ value }) => (value ? new Date(value) : null)) @IsDate() doj: Date; The above code works fine when doj is undefined. It has the same behavior when doj is also null....
mismaah's user avatar
  • 386
1 vote
1 answer
3k views

I've been investigating the topic for a long time. I see the ready solution is absent that works well in NestJS because transformation does not work before validation. If we enable transformation in ...
Victor Shelepen's user avatar
0 votes
1 answer
139 views

The context of the question is a nestjs app, where I'd like to transform a request payload to a different shape, and along with that, verify a certain property on the payload, but then remove it after ...
pointyhat's user avatar
  • 596
2 votes
1 answer
1k views

I have a DTO that looks like this: export class UpdateXXXDto { @IsString() @IsNotEmpty() field1: string; @IsOptional() @IsString() field2: string; @IsOptional() @IsString() field3: ...
Lafi's user avatar
  • 1,352
0 votes
1 answer
175 views

If the user using my decorator does not define "message" in validationOptions my constraint is reported with an empty string ''. export function IsISO6391(validationOptions?: ...
Tiago Bértolo's user avatar
1 vote
0 answers
270 views

I try this approach but when I enter input that shouldn't pass when validate it return [] import { validate } from 'class-validator'; import { plainToClass } from 'class-transformer'; import { MyDTO } ...
Dewvie's user avatar
  • 77
0 votes
1 answer
218 views

I am trying to wrap MUI X Date Picker to a custom component. Here is what I did: export interface IMessage { id?: string | undefined; title?: string | undefined; content?: string | ...
Wasyster's user avatar
  • 2,595
1 vote
1 answer
1k views

I am new to Nest.js and have a good understanding of the overall syntax. However, while creating one of the controllers, I encountered an issue related to the validation of data parsed by the @Headers ...
Shivam Yadav's user avatar
0 votes
1 answer
82 views

I'm using NesteJs, i want @ValidateNested to skip properties that are not defined in the class and not to throw an error: property should not exists This is my classes: export default class ...
AMHF's user avatar
  • 59
0 votes
1 answer
126 views

Maybe I don't understand the DTO, but I want it to check if at least one attribute is sent by the request. How can I do it? Here is my dto: //import libs export class WorkspaceDto { @IsString() ...
green_dino's user avatar
0 votes
1 answer
292 views

I use class-validator to validate query parameters in nest js,why validator does not understand such a syntax as a key ? class Example { @IsOptional() @IsObject() price[$...
Desalutar's user avatar

1
2 3 4 5
9