// Mirrors the frontend's stricter check in lib/validation.ts — a plain
// minLength let obviously-invalid values (e.g. "0000000000") through when
// hit directly via the API, bypassing the UI's real validation.
const MOBILE_PATTERN = '^[6-9][0-9]{9}$';

const clientProperties = {
  name: { type: 'string', minLength: 1 },
  mobile: { type: 'string', pattern: MOBILE_PATTERN },
  alternate_mobile: { type: 'string', pattern: MOBILE_PATTERN, nullable: true },
  email: { type: 'string', format: 'email', nullable: true },
  send_sms: { type: 'boolean', default: false },
};

export const createClientSchema = {
  body: {
    type: 'object',
    required: ['name', 'mobile'],
    properties: clientProperties,
  },
};

export const updateClientSchema = {
  body: {
    type: 'object',
    properties: clientProperties,
  },
};

export const addSealSchema = {
  body: {
    type: 'object',
    required: ['name'],
    properties: { name: { type: 'string', minLength: 1 } },
  },
};
