import Joi from 'joi';

export interface NormalizedErrors {
  /** Original carrier error or regex which represent carrier error */
  source_error: string;
  /** Pattern based on which method will try to match original carrier error. Allowed values "fixed", "regex" */
  match_pattern: string;
  /** Short description of error */
  error_code: string;
  /** Custom error message which will replace standardized error message in response */
  override_custom_error_message?: string;
  /** Module api code when error is related to specific module, not for whole integration */
  source_api_code?: string;
}

export const NormalizedErrorsConfigurationSchema = Joi.object({
  source_error: Joi.string().required(),
  match_pattern: Joi.string().required(),
  error_code: Joi.string().required(),
  override_custom_error_message: Joi.string().optional(),
  source_api_code: Joi.string().optional(),
});
