Skip to content
Advertisement

How to Joi-Allow an empty Date String [Joi]

as the title states, how to allow an empty Date-String through Joi validation.

When adding:

JavaScript

it gets the Issue: message: ""Date" must be a number of milliseconds or valid date string"

with this Joi-Validation:

JavaScript

Question: How can an empty Date-String be allowed through Joi validation?

EDIT: By removing: .required() and or adding .default("") i do get another error, when adding Date: "", Cannot set parameter at row: 1. Wrong input for DATE type

Advertisement

Answer

Valid: Either new Date() or "" (empty string)

joi version 17.2.1

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement