Skip to content
Strata v1.2.6

Validation

Strata uses layered validation — each layer validates what it owns.

Request DTOs use class-validator decorators for shape and type validation.

presentation/dto/asset/create-asset.dto.ts
export class CreateAssetDto {
@IsString()
@IsNotEmpty()
name: string;
@IsUUID()
assetTypeId: string;
@IsOptional()
@IsString()
quantity?: string;
}

Invalid requests receive a 400 Bad Request with validation error details.

Services check business preconditions — entity existence, authorization, etc.

application/services/asset.service.ts
const assetType = await this.assetTypeRepo.findById(command.assetTypeId);
if (!assetType) throw new AssetTypeNotFoundException(command.assetTypeId);

Domain entities enforce business invariants in their constructors or methods.

Prisma enforces @unique constraints, foreign keys, and data types. The repository layer catches Prisma errors and translates them to domain exceptions.

Domain exceptions are mapped to HTTP status codes by the DomainExceptionFilter:

ExceptionHTTP Status
AssetNotFoundException404
CategoryNotFoundException404
TagNotFoundException404
AssetTypeNotFoundException404
DuplicateNameException409
CategoryHasChildrenException409