dashpresshq/dashpress

View on GitHub
src/backend/lib/request/validations/implementations/request-body.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import { progammingError } from "@/backend/lib/errors";
import { validateSchemaRequestBody } from "@/backend/lib/errors/validate-schema-request-input";
import type { IAppliedSchemaFormConfig } from "@/shared/form-schemas/types";

import type { ValidationImplType } from "./types";

export const requestBodyValidationImpl: ValidationImplType<
  Record<string, unknown>
> = async (req, requestValidation: IAppliedSchemaFormConfig<any>) => {
  progammingError("Please provide the request validation", !requestValidation);

  validateSchemaRequestBody(requestValidation, req.body);

  return req.body;
};