MCPcopy Create free account
hub / github.com/codicocodes/speedtyper.dev / validateDTO

Function validateDTO

packages/back-nest/src/utils/validateDTO.ts:15–25  ·  view source on GitHub ↗
(
  dto: ClassConstructor<T>,
  obj: unknown,
)

Source from the content-addressed store, hash-verified

13}
14
15export const validateDTO = async <T>(
16 dto: ClassConstructor<T>,
17 obj: unknown,
18) => {
19 const instance = plainToInstance(dto, obj);
20 const errors = await validate(instance as object);
21 if (errors.length > 0) {
22 throw new ValidationErrorContainer(dto.name, errors);
23 }
24 return instance;
25};

Callers 3

fetchRepositoryMethod · 0.90
fetchTreeMethod · 0.90
fetchBlobMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected