this would be a type safe way to create nested inp...
# orm-help
a
this would be a type safe way to create nested input using the validator, ja? Asking because the example indicates that it isn't possible for it to be type safe unless using a third party tool or package here
Copy code
const userCreate = ({
  email,
  name,
  dob,
  role,
  type,
  provider,
  accessToken,
  providerAccountId,
  isAdmin
}: {
  isAdmin: boolean;
  email: string;
  name: string;
  dob: string;
  role: Role;
  type: string;
  provider: string;
  accessToken: string;
  providerAccountId: string;
}) => {
  return Prisma.validator<
    Prisma.UserCreateInput extends Prisma.AccountCreateInput
      ? Prisma.UserCreateInput & Partial<Prisma.AccountCreateInput>
      : Prisma.UserCreateInput
  >()({
    email,
    isAdmin: role === "USER" ? !isAdmin : !!isAdmin,
    name,
    accounts:
      {
        create: {
          type,
          provider,
          accessToken,
          providerAccountId,
          dob,
          role
        }
      } ?? {}
  });
};
r
Yes. This would just be for TypeScript compile time validation and not runtime.