Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nullable Date #1712

Open
1 of 4 tasks
brantian opened this issue Oct 31, 2024 · 0 comments
Open
1 of 4 tasks

Nullable Date #1712

brantian opened this issue Oct 31, 2024 · 0 comments

Comments

@brantian
Copy link

I have an interface like the following:

interface User {
   name: string,
   deactivate_on? : Date | null
}

The deactivate_on is optional but should be able to be nullable, to set the value as null in the database if it has previously been set with a date.

But if I submit a null value, the request fails as TSOA tries to validate null as a Date:

{
  message: 'Validation error: ',
  details: {
    'requestBody.user_properties.deactivate_on': {
      message: 'invalid ISO 8601 datetime format, i.e. YYYY-MM-DDTHH:mm:ss', 
      value: null
    }
  }
}

Sorting

  • I'm submitting a ...

    • bug report
    • feature request
    • support request
  • I confirm that I

    • used the search to make sure that a similar issue hasn't already been submit

Expected Behavior

Null value should be accepted and processed for the nullable field

Current Behavior

TSOA tries to validate the null value as a Date

Possible Solution

Steps to Reproduce

Context (Environment)

Version of the library: 6.5.1
Version of NodeJS: 18

  • Confirm you were using yarn not npm: [ ]

Detailed Description

Breaking change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant