Joi: Mozilla fire fox is throwing an error with joi date validation

Created on 14 Oct 2020  路  2Comments  路  Source: sideway/joi

@hueniverse

  • is this issue currently blocking your project? (yes/no): yes
  • is this issue affecting a production system? (yes/no):yes

Context

  • node version: 12.19.0
  • module version: "joi": "^17.2.1",
    "react": "^16.13.1",
    "@hapi/joi-date": "^2.0.1",
  • environment (e.g. node, browser, native):
  • used with (e.g. hapi application, another framework, standalone, ...):
  • any other relevant information:

The Schema which am using :
const Joi = require('joi');
const Schema = {
birthday: Joi.date().min('01-01-1960').max('12-31-2003').required()
}

It works fine in google chrome but in mozilla Its throwing an error,
The error is:"Error: date must have a valid date format or reference"
So, I tried to use format() like this:
const Schema = {
birthday: Joi.date().format('MM/DD/YYYY').min('01-01-1960').max('12-31-2003').iso().required()
}
But now mozilla firefox is Throwing:
Error: date must have a valid date format or reference
And google chrome is throwing:
Error: Unknown date format MM/DD/YYYY
Am trying to validate date with min and max date . so can someone please get me a solution for this.
Thanks in Advance

bug

Most helpful comment

Try:

const Joi = require('joi');
const Schema = {
    birthday: Joi.date().min('01/01/1960').max('12/31/2003').required()
}

If that works I'll look at adjusting the strings internally.

All 2 comments

Try:

const Joi = require('joi');
const Schema = {
    birthday: Joi.date().min('01/01/1960').max('12/31/2003').required()
}

If that works I'll look at adjusting the strings internally.

@hueniverse

Thank you for that code... This code is working perfectly...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ashrafkm picture ashrafkm  路  3Comments

normancarcamo picture normancarcamo  路  3Comments

jamesdixon picture jamesdixon  路  4Comments

a-c-m picture a-c-m  路  3Comments

leore picture leore  路  4Comments