Configuration
All options are set inside the generator prismatype { ... } block in your schema.prisma. Values are strings, booleans, or arrays as noted below; Prisma passes them to PrismaType, which coerces them to their declared types.
generator prismatype {
provider = "prismatype"
output = "./prismatype"
inputModel = true
}Common options
output
- Type:
string - Default:
./prismatype
Directory the generated files are written to.
DANGER
This directory is wiped and recreated on every generate. Point it at a folder that PrismaType fully owns.
typeboxImportVariableName
- Type:
string - Default:
"Type"
The variable name used to reference TypeBox in the generated schemas (the standard typebox package exports Type). Set to something else, e.g. "t", if your import uses a different name.
typeboxImportDependencyName
- Type:
string - Default:
"typebox"
The package the TypeBox import comes from. Defaults to the unscoped typebox package (TypeBox >= 1.0). Point this at a package that re-exports the TypeBox 1.x API (e.g. "elysia") if you don't want to import from typebox directly. See Using the Schemas.
additionalProperties
- Type:
boolean - Default:
false
Whether the generated object schemas allow properties beyond those declared. When false, schemas set additionalProperties: false.
inputModel
- Type:
boolean - Default:
false
Enables generation of create/update input models. See Input models for the conventions these rely on.
Input model options
These only take effect when inputModel is enabled. All default to true.
ignoreIdOnInputModel
- Type:
boolean - Default:
true
Omits the @id field from input models.
ignoreCreatedAtOnInputModel
- Type:
boolean - Default:
true
Omits a createdAt DateTime @default(now()) field from input models.
ignoreUpdatedAtOnInputModel
- Type:
boolean - Default:
true
Omits an updatedAt DateTime @updatedAt field from input models.
ignoreForeignOnInputModel
- Type:
boolean - Default:
true
Omits foreign-key fields (those ending in Id) from input models, since relations are handled through connect/disconnect instead.
Advanced options
useJsonTypes
- Type:
false | true | "transformer" - Default:
false
Controls how non-JSON-native types (like DateTime) are emitted so output is compatible with tooling that only supports JSON primitives:
false: off; native types are used.true: such types are emitted as a formattedstring(e.g.Datebecomes astring)."transformer": uses TypeBox codecs (__transformDate__) to accept native JSDatevalues but transform them to strings on processing.
allowRecursion
- Type:
boolean - Default:
true
Whether to allow recursion in the generated schemas. Disabling it reduces generated code size.
additionalFieldsPlain
- Type:
string[] - Default: none
Extra fields to inject into the plain generated schemas. Each entry must be a valid field string in the context where it is used.
generator prismatype {
provider = "prismatype"
inputModel = true
output = "./generated/schema"
additionalFieldsPlain = ["additional: Type.Optional(Type.String())"]
}nullableName
- Type:
string - Default:
"__nullable__"
Name of the generated helper used to wrap nullable fields. See TypeBox & Nullability.
transformDateName
- Type:
string - Default:
"__transformDate__"
Name of the generated date-transform codec used when useJsonTypes is "transformer".
importFileExtension
- Type:
string - Default:
""
File extension added to imports between generated files. Set to ".js" to support nodenext module resolution.
exportedTypePrefix
- Type:
string - Default:
""
Prefix added to every exported schema name.
deriveDbStringConstraints +v1.2.0
- Type:
boolean - Default:
false
When enabled, length-bearing native column types contribute a maxLength constraint to the generated string schema. @db.VarChar(n) and @db.Char(n) (and their provider variants, e.g. NVarChar, NChar) both derive maxLength: n; length-less types like @db.Text derive nothing.
The constraint is applied to the input models only, InputCreate and InputUpdate, where user-supplied data is validated. The plain output model and the Where schemas are left unconstrained.
An explicit @prismatype.options{maxLength: ...} on a field always overrides the derived value, and fields with a @prismatype.typeOverwrite are skipped entirely.
model Item {
id Int @id @default(autoincrement())
name String @db.VarChar(120)
}// InputCreate
name: Type.String({ maxLength: 120 });
// InputUpdate
name: Type.Optional(Type.String({ maxLength: 120 }));
// Plain (unconstrained)
name: Type.String();WARNING
Off by default so regenerating never tightens validation unexpectedly. Enabling it can make previously accepted over-length input fail Value.Check on the input models.