import { z } from 'zod';

/**
 * Gender/Salutation enum
 * Geschlecht/Anrede
 */
export const Gender = {
  NotSet: 0,
  Male: 1,
  Female: 2,
  Diverse: 4,
} as const;

const ALL_FLAGS = Object.values(Gender).reduce<number>((a, b) => a | b, 0);

export const GenderSchema = z
  .nativeEnum(Gender)
  .refine((val) => (val & ALL_FLAGS) === val, {
    message: 'Invalid gender value',
  })
  .describe('Gender/Salutation');

export type Gender = z.infer<typeof GenderSchema>;
