v0.6.0
Minor Changes
-
da90bb2Thanks @kimjbstar! - Pushes the already-supported class-validator/class-transformer integrations further, verified
against Prisma's own schema reference docs and (for the class-validator claim below) the
typestack/class-validatorsource itself:useValidation: postgresql/cockroachdb's@db.Inetnow generates@IsIP()(replacing the
generic@IsString()), and cockroachdb's@db.String(n)— its own name for what postgresql
calls@db.VarChar(n)— now generates@MaxLength(n)like the other length-constrained
string native types already did.useSerialization: a new/// @exposeper-field directive generates class-transformer's
@Expose(), mirroring the existing/// @exclude→@Exclude(), for projects that use
plainToInstance(cls, data, { excludeExtraneousValues: true })'s allow-list model instead of
@Exclude()'s deny-list one.
Deliberately not adding MySQL's
@db.UnsignedBigInt→@Min(0): it maps to Prisma's
BigIntscalar, and class-validator'sMin/Maxrequiretypeof value === 'number'— a JS
BigIntvalue'stypeofis always'bigint', so the decorator would reject every value,
including valid non-negative ones. Confirmed by readingMin.tsin class-validator's own
source, not guessed. -
3d3ca0aThanks @kimjbstar! -useSerializationnow generates class-transformer's@Type(() => X)on relation and
composite-type fields, independently ofuseValidation. Previously@Type()was only
generated as a side effect ofvalidateNestedRelations(which itself requires
useValidation) — so a project usinguseSerializationalone for
ClassSerializerInterceptor-based response serialization never got it, and a nested relation
in a response stayed a plain object instead of an instance of the related class, silently
skipping that class's own@Exclude()/@Expose()decorators.@Type()generation is now a single shared code path: it fires whenuseSerializationis on,
or whenuseValidation+validateNestedRelationsare both on, and doesn't duplicate the
decorator when more than one of those is true at once.