r/ProgrammerHumor • • Oct 13 '26

Meme chaoticEvil

Post image
3.4k Upvotes

262 comments sorted by

View all comments

30

u/themightyug Oct 13 '26

Some of y'all have never had to validate free text input for dates and it shows

9

u/R_Aqua Oct 13 '26

It’s hell on earth for international programs.

6

u/themightyug Oct 13 '26

and users type in the most insane shit into text boxes no matter how clear the instructions are

4

u/ClockificThrowaway Oct 13 '26

Just don’t let them type anything but the exact number of digits you want? My online bank does it well, they even backfill a 0 if you type 7, because that could only be 07, when typing month/year.

4

u/themightyug Oct 13 '26

month and day can be wrong way round too (thanks Americans!) and you can't even tell when the day <= 12

4

u/ClockificThrowaway Oct 13 '26

That’s why you either use a drop down box, or have a rendered date under the entry boxes that spell it out (11. Jan 1999).

In my online bank’s case, it shows “MM/YY” above two text boxes []/[].

4

u/IgnotiusPartong Oct 13 '26

Please write your date of birth in the following line:
"I was born not far from here, must have been 70 years ago now"

Who is going to make sense of this?

3

u/_Agare Oct 13 '26

This was my immediate thought lmao

1

u/JBrockF Oct 13 '26

Seems like a problem that only needs to be solved once though, no?

14

u/Mtsukino Oct 13 '26

Ya, its called a date picker.

1

u/JBrockF Oct 13 '26

If I'm understanding the function here, the date picker actually avoids solving the problem of having to validate free text input, as the date picker is not free text

1

u/Mtsukino Oct 13 '26

You could go about writing a full list of parsing rules if you wanted and implement a box like that, but usually its best practice to give as little input text as possible for an end user. Its more work to keep maintenance of that field when its easier and safer to just chose the date picker that already exists as a library in code.

1

u/JBrockF Oct 13 '26

Yeah i get why it's opted for, it's easier. That doesn't mean it isn't annoying/inefficient for users

1

u/Mtsukino Oct 13 '26

Its easier and safer to have less input that needs scrubbed.

1

u/awesome-alpaca-ace Oct 15 '26

Until the date picker is hacked by the user to give you malicious characters 

1

u/awesome-alpaca-ace Oct 15 '26

Regex is not that hard. You can even write a character by character parser if you want and verify all the characters one by one if it makes the code monkeys happy.

1

u/Mtsukino Oct 15 '26

Lol op of this thread is right. It really shows.

1

u/DarkJarris Oct 16 '26

ah sweet, its not that hard you say? in that case, what does 5/8/1990 validate to?

5th of August, or 8th of May?

date picker will validate it because itll force it to be explicitly picked which is day and which is month as you go through.

I'd love to see the regex that will determine what the user was *thinking* when they wrote 5/8.