import {
  __decorateClass
} from "../../chunk-2E224ZSN.js";

// runtime/pipes/zod-validation.pipe.ts
import {
  BadRequestException,
  Injectable
} from "@nestjs/common";
var ZodValidationPipe = class {
  constructor(schema) {
    this.schema = schema;
  }
  schema;
  transform(value, _metadata) {
    const result = this.schema.safeParse(value);
    if (result.success) {
      return result.data;
    }
    throw new BadRequestException({
      statusCode: 400,
      error: "Bad Request",
      message: "Validation failed",
      issues: formatIssues(result.error.issues)
    });
  }
};
ZodValidationPipe = __decorateClass([
  Injectable()
], ZodValidationPipe);
function formatIssues(issues) {
  return issues.map((issue) => ({
    path: issue.path.join("."),
    code: issue.code,
    message: issue.message
  }));
}
export {
  ZodValidationPipe
};
//# sourceMappingURL=zod-validation.pipe.js.map