refactor!: migrate class-validator to zod (#26597)

This commit is contained in:
Timon
2026-04-14 23:39:03 +02:00
committed by GitHub
parent 3753b7a4d1
commit 7d8f843be6
318 changed files with 7830 additions and 8316 deletions
+15 -23
View File
@@ -1,25 +1,17 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsLatitude, IsLongitude } from 'class-validator';
import { IsGreaterThanOrEqualTo } from 'src/validation';
import { latitudeSchema, longitudeSchema } from 'src/validation';
import z from 'zod';
export class BBoxDto {
@ApiProperty({ format: 'double', description: 'West longitude (-180 to 180)' })
@IsLongitude()
west!: number;
@ApiProperty({ format: 'double', description: 'South latitude (-90 to 90)' })
@IsLatitude()
south!: number;
@ApiProperty({
format: 'double',
description: 'East longitude (-180 to 180). May be less than west when crossing the antimeridian.',
export const BBoxSchema = z
.object({
west: longitudeSchema.describe('West longitude (-180 to 180)'),
south: latitudeSchema.describe('South latitude (-90 to 90)'),
east: longitudeSchema.describe(
'East longitude (-180 to 180). May be less than west when crossing the antimeridian.',
),
north: latitudeSchema.describe('North latitude (-90 to 90). Must be >= south.'),
})
@IsLongitude()
east!: number;
@ApiProperty({ format: 'double', description: 'North latitude (-90 to 90). Must be >= south.' })
@IsLatitude()
@IsGreaterThanOrEqualTo('south')
north!: number;
}
.refine(({ north, south }) => north >= south, {
path: ['north'],
error: 'North latitude must be greater than or equal to south latitude',
})
.meta({ id: 'BBoxDto' });