mirror of
https://github.com/LukeHagar/immich.git
synced 2025-12-09 04:20:12 +00:00
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:
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user