(_schema: TSchema, property: TKey, siblings: TKey[])
| 58 | * Schema.pipe(IsNotSiblingOf(Schema, 'a', ['b'])); |
| 59 | */ |
| 60 | export 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() |
| 78 | export class ParseMeUUIDPipe extends ParseUUIDPipe { |
no outgoing calls
no test coverage detected