Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 23 additions & 17 deletions src/defaultConverters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export const defaultConverters: ISchemaConverters = {
if (typeof meta.target === 'function') {
const typeMeta = options.classTransformerMetadataStorage
? options.classTransformerMetadataStorage.findTypeMetadata(
meta.target,
meta.propertyName
)
meta.target,
meta.propertyName
)
: null
const childType = typeMeta
? typeMeta.typeFunction()
Expand Down Expand Up @@ -141,20 +141,26 @@ export const defaultConverters: ISchemaConverters = {
maximum: meta.constraints[0],
type: 'number',
}),
[cv.MIN_DATE]: (meta) => ({
description: `After ${meta.constraints[0].toJSON()}`,
oneOf: [
{ format: 'date', type: 'string' },
{ format: 'date-time', type: 'string' },
],
}),
[cv.MAX_DATE]: (meta) => ({
description: `Before ${meta.constraints[0].toJSON()}`,
oneOf: [
{ format: 'date', type: 'string' },
{ format: 'date-time', type: 'string' },
],
}),
[cv.MIN_DATE]: (meta) => {
const description = typeof meta.constraints[0] === 'function' ? `After a date computed dynamically` : `After ${meta.constraints[0]}`;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const description = typeof meta.constraints[0] === 'function' ? `After a date computed dynamically` : `After ${meta.constraints[0]}`;
const description = typeof meta.constraints[0] === 'function' ? `After a date computed dynamically` : `After ${meta.constraints[0].toJSON()}`;

return {
description,
oneOf: [
{ format: 'date', type: 'string' },
{ format: 'date-time', type: 'string' },
],
}
},
[cv.MAX_DATE]: (meta) => {
const description = typeof meta.constraints[0] === 'function' ? `Before a date computed dynamically` : `Before ${meta.constraints[0]}`;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const description = typeof meta.constraints[0] === 'function' ? `Before a date computed dynamically` : `Before ${meta.constraints[0]}`;
const description = typeof meta.constraints[0] === 'function' ? `Before a date computed dynamically` : `Before ${meta.constraints[0].toJSON()}`;

return {
description,
oneOf: [
{ format: 'date', type: 'string' },
{ format: 'date-time', type: 'string' },
],
}
},
[cv.IS_BOOLEAN_STRING]: {
enum: ['true', 'false'],
type: 'string',
Expand Down