This file contains the changes made to the package.
The sections are in descending order of the change date.
3.3.0 - 2023-09-28
- Support for
NativeEnum
s. parseToInstance
option to let users/consumers choose if the successfulzod
validation should parse to the instance of dynamically generated class.
3.2.0 - 2023-05-16
-
Now
.int()
can be used and it will haveGraphQLInt
type. Previously it was alwaysFloat
type.Thanks Ugzuzg for their contribution.
- Dependencies are now moved to
peerDependencies
.
3.1.0 - 2023-04-05
-
setDefaultEnumProvider
function.This can be used to provide types for enums parsed from the zod schema. Use this function to return your custom, already registered GraphQL enums instead of dynamic, parsed zod enum. By this way, it would prevent multiple identical enums being generated.
-
Added
getDefaultEnumProvider
function.This function gets the previously set enum provider function through
setDefaultEnumProvider
.
These functions are also added to the options of @ZodArgs()
.
3.0.0 - 2023-03-27
-
setDefaultTypeProvider
function which can be used to provide custom GraphQL scalar types for complex types. This function will receive a handler function which will take the built name representation of the type that is built from the zod schema and return aGraphQLScalarType
to represent that custom type.The built name for complex types will be similar to TypeScript types, such as:
Record<Optional<String>, Array<Number | String>>
. For example, for this type it is possible to return aJSONObject
scalar type to represent this zod type.This Type Provider function can be set through this function and also via the decorator properties. Hence, it is possible to set different handlers for different decorators.
-
Support for primitives at
@ZodArgs
decoratorNow it is possible to pass a primitive value validator or array of it, example:
@ZodArgs(z.number().gt(10).optional().array()) input: number[]
And this decorator will be validating the input passed to the parameter without creating a proxy type for it (as it is primitive).
-
Added
getZodObjectName
function.This function takes any zod type and builds a string representing the zod structure like TypeScript types as the example above.
- Description parsing is improved. Now the description properties of fields
will still be extracted if they are under different zod effects such as
Optional
orNullable
orArray
etc. - Improved error messages during parsing. Now the error messages will provide a string that represents the schema that caused the error.
IModelFromZodOptionsWithMapper<T>
interface is removed which means thatpropertyMap
will not be provided any more, there will be no renaming when a zod is being converted to a class.types.d.ts
file.
2.0.3 - 2023-02-07
- Provides safe naming mechanism. Now using same name for different or same schemes will not cause error.
- Now returns the same dynamic class for same zod scheme input for
@ZodArgs()
.
2.0.2 - 2022-09-28
- The behavior of error handling has been changed. If an error is thrown from
the method body, then the error will not be modified. If a zod validation
error occurs, the zod error will always be placed in a
BadRequestException
.
2.0.1 - 2022-09-27
- Nested classes were causing to register the top most class multiple times.
2.0.0 - 2022-08-23
.transform
support. Nowzod
objects/properties may havetransform
calls.
- Renamed
InputZodType
decorator toZodArgs
. - Renamed
InputTypeFromZod
toinputFromZod
. README
file.
1.0.0 - 2022-08-23
- New decorators for
InputType
withzod
validations:-
ZodArgs
: Takes azod
validation object and can be used in place ofArgs
. If the validation fails,BadRequest
exception will be thrown. The correspondingGraphQL
schema objects will be created according to the givenzod
input. -
InputTypeWithZod
: This is a helper decorator that might be used rarely. When applied with azod
validation object to a class, the properties found in the class will be decorated withField
property and the class will be decorated withInputType
decorator. -
ZodArgs.Of<T>
: This is a type that will infer the type from azod
validation object.
-
- Previosuly default values were being incorrectly set.
0.1.5 - 2022-05-08
When an error occurs, the issues
are placed in BadRequestException
body.
0.1.3 - 2022-05-08
Type checking strategy is moved to a function file, all type checking will be
done through isZodInstance
function.
0.1.2 - 2022-05-08
Type checking strategy is now changed to constructor name comparison.
0.1.1 - 2022-05-08
The initial version of the package.