fastest-validator-nestjs
v0.3.1
Published
NestJS package for fastest-validator
Downloads
1,371
Maintainers
Readme
Fastest Validation Combined with nestjs
@ValidationSchema({
strict: true
})
class NestedEntity {
@Alphabet({ min: 5 })
prop7: string;
}
@ValidationSchema({
strict: true
})
class MyBody {
@UUID()
prop1: string;
@Enum({ values: ["one", "two"] })
prop2: "one" | "two";
@Email()
prop3: string;
@Numeric({ positive: true })
prop4: number;
@NestedObject()
prop5: NestedEntity;
@ArrayOf({
items: NestedEntity
})
prop6: NestedEntity[];
}
Then in your controller
add the class
:
@Post()
postHello(
@Body() body: MyBody
): string {
return helloFvn();
}
And in the main.ts` add these lines:
app.useGlobalPipes(new FastestValidatorPipe());
app.useGlobalFilters(new FastestValidatorExceptionFilter({
showStack: false
})
);