mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +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:
parent
df2525ee08
commit
011a667314
19 changed files with 574 additions and 52 deletions
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue