-
Notifications
You must be signed in to change notification settings - Fork 520
Closed
Labels
type: questionQuestions about the usage of the library.Questions about the usage of the library.
Description
It's probably a not very easy thing to do, but ultimately it would be great to utilize Typescript typings instead of explicitly declaring validation types.
Instead of:
@IsString()
a: stringJust:
a: string // @IsString() inferred, also @IsDefined inferred
b?: string // @IsString(), @IsOptional inferred from "?"I was able to achieve that in a long way, by:
- Using https://github.com/YousefED/typescript-json-schema during build step to generate json schemas, that know about types, also if fields are required or not, and some more things.
- Use json-schema validator in runtime (there are many) that consume schema generated in step 1 and give validation errors.
Result is that I have type and required/optional validation "inferred" from Typescript.
Any ideas how to achieve that with class-transformer, to utilize the beauty of @annotations (to combine inferred types with custom annotations and use all other features of class-transformer).
nolazybits
Metadata
Metadata
Assignees
Labels
type: questionQuestions about the usage of the library.Questions about the usage of the library.