django-rest-framework icon indicating copy to clipboard operation
django-rest-framework copied to clipboard

input type="date" validation message incorrect

Open mangelozzi opened this issue 2 years ago • 2 comments

If one has a date, that is blank and gets posted to the server, the server responds with:

Date has wrong format. Use one of these formats instead: YYYY-MM-DD.

This used to be correct when all date's where in the format YYYY-MM-DD. But with chrome 116 and locale set to South African English, my browser shows it in the format DD-MM-YYYY. This is confusing to the user, because the way its shown to the user is not the way the <input type="date"> reports it.

Here's an example: image

This means unless your countries locale is in the format of YYYY-MM-DD, i.e. almost everyone except Swedan, then the error message is misleading to the user. Maybe The error message should just be: ``Date has wrong format, which does sound like great english to me... how about Date format is invalid`

PS this can't be fixed on the backend, because it's does not know what the front end locale is.

mangelozzi avatar Dec 21 '23 12:12 mangelozzi

So, exactly what you want with it ?

Tyeion avatar Jan 16 '24 05:01 Tyeion

An error message that is not misleading/incorrect. Maybe to just shorten the error message to "Date has the wrong format".

mangelozzi avatar Jan 16 '24 11:01 mangelozzi

this can't be fixed on the backend

There's an unavoidable trade-off between what's typically the most sensible behaviour for us here. I'd we treat this as out of scope, and suggest using custom error messages.

lovelydinosaur avatar Mar 21 '24 14:03 lovelydinosaur