All files / src/presentation/http/schemas legal.schema.ts

100% Statements 4/4
100% Branches 0/0
100% Functions 0/0
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32            21x   21x                           21x           21x      
import { z } from 'zod';
 
/**
 * The two documents a user can accept. Lowercase because these values are the frontend's document
 * registry (`shared/legal.ts`), which is the single source of both the id and the version.
 */
const legalDocumentIdSchema = z.enum(['privacy', 'terms']);
 
export const recordLegalAcceptanceBodySchema = z.object({
  documentId: legalDocumentIdSchema,
  version: z
    .string()
    .trim()
    .min(1)
    .max(64)
    .describe(
      'The exact version string of the document that was shown and accepted. Accepting a version ' +
        'other than the one currently in force is recorded as given — it is a fact about the past, ' +
        'not a claim about the current text.',
    ),
});
 
export const legalAcceptanceResponseSchema = z.object({
  documentId: legalDocumentIdSchema,
  version: z.string(),
  acceptedAt: z.string().datetime(),
});
 
export const legalAcceptanceListResponseSchema = z.array(legalAcceptanceResponseSchema);
 
export type RecordLegalAcceptanceBody = z.infer<typeof recordLegalAcceptanceBodySchema>;