MCPcopy
hub / github.com/immich-app/immich / IsNotSiblingOf

Function IsNotSiblingOf

server/src/validation.ts:60–75  ·  view source on GitHub ↗
(_schema: TSchema, property: TKey, siblings: TKey[])

Source from the content-addressed store, hash-verified

58 * Schema.pipe(IsNotSiblingOf(Schema, 'a', ['b']));
59 */
60export function IsNotSiblingOf<
61 TSchema extends z.ZodObject<z.ZodRawShape>,
62 TKey extends z.infer<ReturnType<TSchema['keyof']>> & keyof z.infer<TSchema>,
63>(_schema: TSchema, property: TKey, siblings: TKey[]) {
64 type T = z.infer<TSchema>;
65 const message = `${String(property)} cannot exist alongside ${siblings.join(' or ')}`;
66 return z.custom<T>().refine(
67 (data) => {
68 if (data[property] === undefined) {
69 return true;
70 }
71 return siblings.every((sibling) => data[sibling] === undefined);
72 },
73 { message },
74 );
75}
76
77@Injectable()
78export class ParseMeUUIDPipe extends ParseUUIDPipe {

Callers 2

validation.spec.tsFile · 0.90
asset.dto.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected