prisma-class-validator
Version:
Automatically generator class-validator schema from Prisma client
188 lines (153 loc) • 3.46 kB
JavaScript
"use strict";
/**
* @copyright Koj <https://koj.co>
* @link https://github.com/koj-co/prisma-class-validator
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
const prettier_1 = require("prettier");
const _1 = require("./");
test("generate schema", () => {
expect(_1.generateClassValidatorFromPrismaClient(`
/**
* Client
**/
import * as runtime from '@prisma/client/runtime';
/**
* Model Lead
*/
export type Lead = {
browser: string | null
city: string | null
countryCode: string | null
createdAt: Date
email: string
id: number
name: string
operatingSystem: string | null
region: string | null
responses: Prisma.JsonValue | null
timezone: string | null
updatedAt: Date
}
/**
* Model User
*/
export type User = {
active: boolean
attributes: Prisma.JsonValue | null
checkLocationOnLogin: boolean
countryCode: string
createdAt: Date
gender: Gender
}
/**
* Enums
*/
// Based on
// https://github.com/microsoft/TypeScript/issues/3192#issuecomment-261720275
export const Gender: {
FEMALE: 'FEMALE',
MALE: 'MALE',
NONBINARY: 'NONBINARY',
UNKNOWN: 'UNKNOWN'
};
export type Gender = (typeof Gender)[keyof typeof Gender]
`)).toBe(prettier_1.format(`
/**
* DO NOT EDIT THIS FILE MANUALLY
* ==============================
*
* This file is automatically generated by Prisma Class Validator using @prisma/client
* Source: https://github.com/koj-co/prisma-class-validator/blob/HEAD/scripts/generate-types.ts
*/
import {
IsOptional,
IsString,
IsNumber,
IsNotEmpty,
IsBoolean,
IsObject,
IsDateString,
IsIn,
} from "class-validator";
/**
* Model Lead
*/
export class Lead {
browser?: string | null;
city?: string | null;
countryCode?: string | null;
createdAt!: Date;
email!: string;
id!: number;
name!: string;
operatingSystem?: string | null;
region?: string | null;
responses?: any | null;
timezone?: string | null;
updatedAt!: Date;
}
/**
* Model User
*/
export class User {
active!: boolean;
attributes?: any | null;
checkLocationOnLogin!: boolean;
countryCode!: string;
createdAt!: Date;
gender!: Gender;
}
/**
* Enums
*/
// Based on
// https://github.com/microsoft/TypeScript/issues/3192#issuecomment-261720275
export let Gender: {
FEMALE: "FEMALE";
MALE: "MALE";
NONBINARY: "NONBINARY";
UNKNOWN: "UNKNOWN";
};
export type Gender = typeof Gender[keyof typeof Gender];
`, { parser: "typescript" }));
});
//# sourceMappingURL=index.spec.js.map