feat: batch change date and time relatively (#17717)

Co-authored-by: marcel.kuehne <>
Co-authored-by: Zack Pollard <zackpollard@ymail.com>
This commit is contained in:
mkuehne707 2025-08-07 15:42:33 +02:00 committed by GitHub
parent df2525ee08
commit 011a667314
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 574 additions and 52 deletions

View file

@ -1,7 +1,8 @@
import { plainToInstance } from 'class-transformer';
import { validate } from 'class-validator';
import { DateTime } from 'luxon';
import { IsDateStringFormat, MaxDateString } from 'src/validation';
import { IsDateStringFormat, IsNotSiblingOf, MaxDateString, Optional } from 'src/validation';
import { describe } from 'vitest';
describe('Validation', () => {
describe('MaxDateString', () => {
@ -54,4 +55,38 @@ describe('Validation', () => {
await expect(validate(dto)).resolves.toHaveLength(1);
});
});
describe('IsNotSiblingOf', () => {
class MyDto {
@IsNotSiblingOf(['attribute2'])
@Optional()
attribute1?: string;
@IsNotSiblingOf(['attribute1', 'attribute3'])
@Optional()
attribute2?: string;
@IsNotSiblingOf(['attribute2'])
@Optional()
attribute3?: string;
@Optional()
unrelatedAttribute?: string;
}
it('passes when only one attribute is present', async () => {
const dto = plainToInstance(MyDto, { attribute1: 'value1', unrelatedAttribute: 'value2' });
await expect(validate(dto)).resolves.toHaveLength(0);
});
it('fails when colliding attributes are present', async () => {
const dto = plainToInstance(MyDto, { attribute1: 'value1', attribute2: 'value2' });
await expect(validate(dto)).resolves.toHaveLength(2);
});
it('passes when no colliding attributes are present', async () => {
const dto = plainToInstance(MyDto, { attribute1: 'value1', attribute3: 'value2' });
await expect(validate(dto)).resolves.toHaveLength(0);
});
});
});