omar-dulaimi / prisma-yup-generator

Prisma 2+ generator to emit Yup schemas from your Prisma schema
MIT License
53 stars 3 forks source link

Fix for "// @ts-nocheck" #14

Open nightness opened 1 year ago

nightness commented 1 year ago

Bug description

// @ts-nocheck suppresses errors

oneOfSchemas.helper.ts

import * as Yup from "yup";
declare module "yup" {
  interface MixedSchema {
    oneOfSchemas(schemas: Array<Yup.Schema<any>>): this;
  }
}
Yup.addMethod<Yup.MixedSchema>(
  Yup.mixed,
  "oneOfSchemas",
  function (schemas: Array<Yup.Schema<any>>) {
    return this.test(
      "one-of-schemas",
      "Not all items in [object Object] match one of the allowed schemas",
      (item) =>
        schemas.some((schema) =>
          schema.isValidSync(item, {
            strict: true,
          })
        )
    );
  }
);

How to reproduce

Not applicable

Expected behavior

No response

Prisma information

Not Applicable

Environment & setup

Prisma Version

Not Applicable