Skip to content

Commit

Permalink
deprecated some objects
Browse files Browse the repository at this point in the history
  • Loading branch information
chrishoermann committed Apr 6, 2023
1 parent bb025ec commit c833cd9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/generator/package.json
@@ -1,6 +1,6 @@
{
"name": "zod-prisma-types",
"version": "2.5.4",
"version": "2.5.5",
"description": "Generates zod schemas from Prisma models with advanced validation",
"author": "Chris Hörmann",
"license": "MIT",
Expand Down
16 changes: 16 additions & 0 deletions packages/generator/src/constants/objectMaps.ts
Expand Up @@ -27,6 +27,7 @@ import {
/////////////////////////////////////////////////

/**
* @deprecated
* Map all `validators` that can be used in the documentation of the prisma.schema
* to the prisma scalar types on which this `validator` is allowed.
*
Expand Down Expand Up @@ -82,6 +83,9 @@ export const PRISMA_TO_ZOD_TYPE_MAP: Record<
// ZOD VALID ERROR KEYS
/////////////////////////////////////////////////

/**
* @deprecated
*/
export const ZOD_VALID_ERROR_KEYS: ZodCustomErrorKey[] = [
'invalid_type_error',
'required_error',
Expand All @@ -92,16 +96,23 @@ export const ZOD_VALID_ERROR_KEYS: ZodCustomErrorKey[] = [
// REGEX MAPS
/////////////////////////////////////////////

/**
* @deprecated
*/
export type ValidatorMapValue =
| RegExp
| ((pattern: string) => string | undefined);

/**
* @deprecated
*/
export type ValidatorMap<TKeys extends string> = Record<
TKeys,
ValidatorMapValue
>;

/**
* @deprecated
* Maps the right regex to the right validator key.
*
* Used to determine if a validator key is valid for a `string` type.
Expand All @@ -126,6 +137,7 @@ export const STRING_VALIDATOR_REGEX_MAP: ValidatorMap<ZodStringValidatorKeys> =
};

/**
* @deprecated
* Maps the right regex to the right validator key.
*
* Used to determine if a validator key is valid for a `number` type.
Expand All @@ -149,6 +161,7 @@ export const NUMBER_VALIDATOR_REGEX_MAP: ValidatorMap<ZodNumberValidatorKeys> =
};

/**
* @deprecated
* Maps the right regex to the right validator key.
*
* Used to determine if a validator key is valid for a `date` type.
Expand All @@ -160,6 +173,9 @@ export const DATE_VALIDATOR_REGEX_MAP: ValidatorMap<ZodDateValidatorKeys> = {
max: DATE_VALIDATOR_NUMBER_AND_MESSAGE_REGEX,
};

/**
* @deprecated
*/
export const CUSTOM_VALIDATOR_REGEX_MAP: ValidatorMap<ZodCustomValidatorKeys> =
{
use: (pattern) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/usage/prisma/schema.prisma
Expand Up @@ -90,7 +90,7 @@ model ModelWithComments {
// It should not matter if the comments are above or next to the field

/// comment line one
/// @zod.import(["import { myFunction } from "../../../../utils/myFunction";", "import validator from 'validator';"])
/// @zod.import(["import { myFunction } from "../../../../utils/myFunction";", "import validator from 'validator';", "import some from "my-package";"])
/// comment line two
model MyPrismaScalarsType {
/// @zod.string({ invalid_type_error: "some error with special chars: some + -*#'substring[]*#!§$%&/{}[]", required_error: "some other", description: "some description" }).cuid()
Expand Down

0 comments on commit c833cd9

Please sign in to comment.