2,156 questions
Best practices
0
votes
1
replies
40
views
How should shared DTOs be managed across API, Application, and Frontend layers in a .NET 9 Clean Architecture project?
I’m working on a .NET 9 Clean Architecture solution with the following structure:
API – ASP.NET Core Web API (.NET 9)
Application – Application services and business logic
Domain – Core domain ...
3
votes
1
answer
80
views
In Laravel’s Repository pattern, should I pass an Eloquent model (User $user) or a DTO to keep it framework-agnostic?
I’m refactoring my Laravel application to follow a clean architecture approach with clear separation of concerns:
Controller → Service → Repository
The Controller handles the HTTP layer,the Service ...
0
votes
0
answers
50
views
nestjs use i18n in decorators of class-validator without indicate one by one
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;
}...
1
vote
1
answer
25
views
FastifyAdapter bypasses global ValidationPipe for tz, resulting in 400 whitelistValidation error in production builds
FastifyAdapter bypasses global ValidationPipe for tz, resulting in 400 whitelistValidation error in production builds
Description
I’m experiencing an issue where my global ValidationPipe is correctly ...
-1
votes
2
answers
57
views
Get property from nested object
I have this DTO:
import { Expose, Type } from 'class-transformer';
import { UserDto } from '../../../admin/users/dtos/user.dto';
export class CompanyDto {
constructor(partial: Partial<CompanyDto&...
0
votes
1
answer
64
views
NestJS ValidationPipe with ValidateIf not preventing conditional field validation
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:
...
1
vote
1
answer
68
views
class-validator whitelisting properties of object inside array
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 ...
0
votes
1
answer
257
views
DTO at hexagonal architecture
I am recently working on hexagonal architecture test with java and spring boot, and i am trying to implement DTOs, i have a service class and this class inherits from four interfaces, ICreateProduct, ...
0
votes
1
answer
246
views
Nest js union dto types
I have a nestjs dto classes. Use it for response dto.
class A {
response: '1',
prop1: string
}
class B {
response: '2',
prop2: string
}
Everything works
function foo ():A|B {
const result:...
0
votes
2
answers
47
views
Entity Framework linq bool response
I have 3 tables: main account, activities & trades.
What I want is to return a bool, based on wither or not a main account has any trades associated with it (connect via an account id column in ...
0
votes
1
answer
201
views
DTOs in Hexagonal Architecture
I have a problem with the structure of my API.
My API includes the study domain class, which has an educationLevelId attribute; This attribute belongs to the academicLevel domain class.
Study Domain - ...
0
votes
1
answer
151
views
Nestjs Swagger not showing correctly for circular/nested dependency DTOs
I'm working with a nested structure in TypeScript where each CategoryDTO can contain child entities (childEntities), which can be either CategoryDTO (categories) or ProductDTO (products).
However the ...
0
votes
0
answers
49
views
Java abstract service with abstract mappers
To reduce the amount of code, I thought of creating an abstract service like that (it is just a "sketch"):
public abstract class CrudService<E extends EntityWithId<ID>,ID,R extends ...
-1
votes
2
answers
250
views
How to use a single DTO class in .NET 8.0 instead of multiple DTOs for various endpoints [closed]
In my .NET Core application, assume I have 10 API endpoints and each endpoint has a DTO. Now I need to consolidate this 10 endpoints into 1 endpoint with http GET method. How to merge all 10 DTOs into ...
0
votes
1
answer
80
views
ValidationPipe doesn't transform string to number
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 - ...
0
votes
0
answers
176
views
How to define correctly a converter in ModelMapper library for DTO
I have two JPA entities: Person and Address and three DTOs called: PersonDto, AddressDto and BasicAddressDto. The class AddressDto extends BasicAddressDto.
PersonDto has a property called address (...
0
votes
1
answer
88
views
How to Ensure Type Safety in TypeScript When Transforming Objects Through Multiple Stages?
I'm working on a NestJS application where I need to create different types of entities (like Users, Products, Orders, etc.) and apply some transformations before saving them to the database. ...
0
votes
0
answers
519
views
Difference between DTO (Data Transfer Object) and model class
While doing R&D about DTO, I am unclear about the difference between the model class and a DTO. I searched for some information about that.
Model - has the data handle and business logic
DTO - ...
0
votes
1
answer
336
views
API Platform custom Controller serialization problem
I have a very simple custom API endpoint with an input and output DTO and a Symfony Controller, build like the examples in the documentation page: https://api-platform.com/docs/v2.3/core/dto/
#[...
0
votes
0
answers
266
views
How to define optional properties in Data Transfer Objects?
Below is my Data Transfer Object using Spatie\LaravelData\Data using Laravel Framework 9.52.16. In this definition $user_id is defined as optional property but yet when it is missing it throws an ...
1
vote
1
answer
1k
views
DTO on hexagonal architecture and DDD
I've a spring application (webservice that connect to a database and retrieve data) using a hexagonal architecture and DDD (Domain-Driven Design).
The basic struture is
Application
Controller to ...
0
votes
1
answer
124
views
Parameters in @Query Annotation for DTO Class Spring Boot 3
I want to use this following DTO-Class to project the Entity-Object in my project in the purpose to retrieve the corresponding information related to my profile depending on id's value given as ...
0
votes
0
answers
46
views
is it good practice to compute booleans inside dto?
Here is my code, where the !!name && !!familyRole && !!gender part is computing isOnboarded value. Is it good practice to do such calculations inside DTO class ?
import { UserDocument }...
1
vote
1
answer
102
views
How to map (select) specific set of data from db entity in Clean Architecture without load entire entities
I hope you are all doing well. I am currently working on a multi-layered application and have encountered a few challenges that I would appreciate your input on.
Here's the situation:
I have an ...
0
votes
1
answer
412
views
Spring Boot Rest - How to map headers to a DTO
i'm using Spring Boot and need to access multiple values from the request headers, the problem is that @RequestHeader it only accepts a single property at a time. Instead of declaring individual ...