-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved error messages for class-validator
- Loading branch information
Showing
6 changed files
with
167 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@typeschema/class-validator': minor | ||
'@typeschema/main': patch | ||
'@typeschema/all': patch | ||
--- | ||
|
||
Improved error messages for class-validator |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,11 +44,13 @@ describe('class-validator', () => { | |
@IsDateString() | ||
updatedAt!: string; | ||
|
||
@IsOptional() | ||
@ValidateNested() | ||
nested!: NestedSchema; | ||
nested?: NestedSchema; | ||
|
||
@IsOptional() | ||
@ValidateNested() | ||
nestedArray?: NestedSchema[]; | ||
nestedArray?: Array<NestedSchema>; | ||
} | ||
const schema = Schema; | ||
|
||
|
@@ -67,7 +69,7 @@ describe('class-validator', () => { | |
email: '[email protected]', | ||
id: 'c4a760a8-dbcf-4e14-9f39-645a8e933d74', | ||
name: 'John Doe', | ||
updatedAt: '2021-01-01T00:00:00.000Z' | ||
updatedAt: '2021-01-01T00:00:00.000Z', | ||
}; | ||
|
||
const badNestedData = { | ||
|
@@ -100,7 +102,7 @@ describe('class-validator', () => { | |
{ | ||
message: 'age must be an integer number', | ||
path: ['age'], | ||
} | ||
}, | ||
], | ||
success: false, | ||
}); | ||
|
@@ -109,20 +111,20 @@ describe('class-validator', () => { | |
issues: [ | ||
{ | ||
message: 'value should not be empty', | ||
path: ['nested.value'], | ||
path: ['nested', 'value'], | ||
}, | ||
{ | ||
message: 'value must be a string', | ||
path: ['nested.value'], | ||
path: ['nested', 'value'], | ||
}, | ||
{ | ||
message: 'value should not be empty', | ||
path: ['nestedArray[0].value'], | ||
path: ['nestedArray', 0, 'value'], | ||
}, | ||
{ | ||
message: 'value must be a string', | ||
path: ['nestedArray[0].value'], | ||
} | ||
path: ['nestedArray', 0, 'value'], | ||
}, | ||
], | ||
success: false, | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.