/**
 * Validation Error Catalog
 *
 * Defines all validation related errors excluding file validation.
 */

import { ErrorCategory, ErrorEntry } from '../types';
import { FILE_VALIDATION_ERRORS } from './file';

export const VALIDATION_ERRORS: Record<string, ErrorEntry> = {
	// Platform errors
	MISSING_PLATFORM_HEADER: {
		code: 'MISSING_PLATFORM_HEADER',
		httpStatus: 422,
		category: ErrorCategory.VALIDATION,
		severity: 'low',
		message: {
			vi: 'Thiếu header platform',
			en: 'Missing platform header',
		},
	},
	INVALID_PLATFORM: {
		code: 'INVALID_PLATFORM',
		httpStatus: 422,
		category: ErrorCategory.VALIDATION,
		severity: 'low',
		message: {
			vi: 'Platform không hợp lệ',
			en: 'Invalid platform',
		},
	},

	// Validation errors
	VALIDATION_ERROR: {
		code: 'VALIDATION_ERROR',
		httpStatus: 422,
		category: ErrorCategory.VALIDATION,
		severity: 'low',
		logToSentry: false,
		userVisible: true,
		message: {
			vi: 'Dữ liệu không hợp lệ',
			en: 'Invalid data',
		},
	},
	INVALID_EMAIL_FORMAT: {
		code: 'INVALID_EMAIL_FORMAT',
		httpStatus: 422,
		category: ErrorCategory.VALIDATION,
		severity: 'low',
		message: {
			vi: 'Email không hợp lệ',
			en: 'Invalid email format',
		},
	},
	INVALID_UUID_FORMAT: {
		code: 'INVALID_UUID_FORMAT',
		httpStatus: 422,
		category: ErrorCategory.VALIDATION,
		severity: 'low',
		message: {
			vi: 'ID không hợp lệ',
			en: 'Invalid ID format',
		},
	},
	INVALID_URL_FORMAT: {
		code: 'INVALID_URL_FORMAT',
		httpStatus: 422,
		category: ErrorCategory.VALIDATION,
		severity: 'low',
		message: {
			vi: 'URL không hợp lệ',
			en: 'Invalid URL format',
		},
	},
	INVALID_PHONE_FORMAT: {
		code: 'INVALID_PHONE_FORMAT',
		httpStatus: 422,
		category: ErrorCategory.VALIDATION,
		severity: 'low',
		message: {
			vi: 'Số điện thoại không hợp lệ',
			en: 'Invalid phone number format',
		},
	},
	PASSWORD_TOO_SHORT: {
		code: 'PASSWORD_TOO_SHORT',
		httpStatus: 422,
		category: ErrorCategory.VALIDATION,
		severity: 'low',
		message: {
			vi: 'Mật khẩu quá ngắn',
			en: 'Password is too short',
		},
	},
	PASSWORD_BREACHED: {
		code: 'PASSWORD_BREACHED',
		httpStatus: 422,
		category: ErrorCategory.VALIDATION,
		severity: 'low',
		message: {
			vi: 'Mật khẩu đã bị lộ',
			en: 'Password has been breached',
		},
	},
	PASSWORD_CONTAINS_PERSONAL_INFO: {
		code: 'PASSWORD_CONTAINS_PERSONAL_INFO',
		httpStatus: 422,
		category: ErrorCategory.VALIDATION,
		severity: 'low',
		message: {
			vi: 'Mật khẩu chứa thông tin cá nhân',
			en: 'Password contains personal information',
		},
	},
	VALUE_TOO_SHORT: {
		code: 'VALUE_TOO_SHORT',
		httpStatus: 422,
		category: ErrorCategory.VALIDATION,
		severity: 'low',
		message: {
			vi: 'Giá trị quá ngắn',
			en: 'Value is too short',
		},
	},
	VALUE_TOO_LONG: {
		code: 'VALUE_TOO_LONG',
		httpStatus: 422,
		category: ErrorCategory.VALIDATION,
		severity: 'low',
		message: {
			vi: 'Giá trị quá dài',
			en: 'Value is too long',
		},
	},
	INVALID_STRING_TYPE: {
		code: 'INVALID_STRING_TYPE',
		httpStatus: 422,
		category: ErrorCategory.VALIDATION,
		severity: 'low',
		message: {
			vi: 'Phải là văn bản',
			en: 'Must be a string',
		},
	},
	INVALID_NUMBER_TYPE: {
		code: 'INVALID_NUMBER_TYPE',
		httpStatus: 422,
		category: ErrorCategory.VALIDATION,
		severity: 'low',
		message: {
			vi: 'Phải là số',
			en: 'Must be a number',
		},
	},
	INVALID_BOOLEAN_TYPE: {
		code: 'INVALID_BOOLEAN_TYPE',
		httpStatus: 422,
		category: ErrorCategory.VALIDATION,
		severity: 'low',
		message: {
			vi: 'Phải là đúng/sai',
			en: 'Must be a boolean',
		},
	},
	INVALID_TYPE: {
		code: 'INVALID_TYPE',
		httpStatus: 422,
		category: ErrorCategory.VALIDATION,
		severity: 'low',
		message: {
			vi: 'Giá trị không hợp lệ',
			en: 'Invalid type',
		},
	},
	INVALID_FORMAT: {
		code: 'INVALID_FORMAT',
		httpStatus: 422,
		category: ErrorCategory.VALIDATION,
		severity: 'low',
		message: {
			vi: 'Định dạng không hợp lệ',
			en: 'Invalid format',
		},
	},
	INVALID_CODE: {
		code: 'INVALID_CODE',
		httpStatus: 422,
		category: ErrorCategory.VALIDATION,
		severity: 'low',
		message: {
			vi: 'Mã xác thực không hợp lệ',
			en: 'Invalid verification code',
		},
	},
	...FILE_VALIDATION_ERRORS,
};
