Skip to content

Commit

Permalink
upgraded version of class-validator (epiphone#95)
Browse files Browse the repository at this point in the history
* upgraded version of class-transformer

* fix: don't modify metadata storage of class validator

* formatting

* fixed comments & npm audit fix

* better types
  • Loading branch information
willemgovaerts authored Jan 7, 2023
1 parent 625eb19 commit 59b3799
Show file tree
Hide file tree
Showing 4 changed files with 305 additions and 957 deletions.
16 changes: 10 additions & 6 deletions __tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
IsString,
Length,
MaxLength,
MetadataStorage,
MinLength,
ValidateNested,
} from 'class-validator'
Expand Down Expand Up @@ -61,8 +62,9 @@ class Post {
describe('classValidatorConverter', () => {
it('handles empty metadata', () => {
const emptyStorage: any = {
constraintMetadatas: [],
validationMetadatas: [],
constraintMetadatas: new Map(),
validationMetadatas: new Map(),
getTargetValidatorConstraints: () => [],
}

expect(
Expand All @@ -85,10 +87,12 @@ describe('classValidatorConverter', () => {
type: 'NON_EXISTENT_METADATA_TYPE',
validationTypeOptions: {},
}
const storage: any = {
constraintMetadatas: [],
validationMetadatas: [customMetadata],
}

const storage = ({
constraintMetadatas: new Map(),
validationMetadatas: new Map([[User, [customMetadata]]]),
getTargetValidatorConstraints: () => [],
} as unknown) as MetadataStorage

const schemas = validationMetadatasToSchemas({
classValidatorMetadataStorage: storage,
Expand Down
Loading

0 comments on commit 59b3799

Please sign in to comment.