• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validations Required or not..

 
Nitin Gupte
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any validation for dates required to be implemented.. or can i assume that they will be entered correctly?
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would not assume such thing if I were you. I would certainly validate that the provided values represent a valid date. I do not believe it is a good idea to let your applications store a date like 02/31/2006 (which does not exist).

But, I believe there is more than that. You could come up with a few business rules applicable to dates in the context of your application.

For instance, it does not make sense to book a room in a past date. Bookigs will always be in a future date and they can only be within a period of 48 hours and things like that (depending on your specs).

Also if you are not providing any localization in your app check at least that the dates are formatted as other dates in your database file. On the other hand, if you are providing localization, make sure you store the dates following the same format that other dates in the file do.

I hope this helps!
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

Nitin,
you can use a JFormattedTextField with a right formatter to constrain the user to enter the right date.
But why you need the this feature, I mean that the user must specify a date ?

Edwin,

it does not make sense to book a room in a past date


Of course is possible to book room in in the past, you only need a a time machine to reach it.
Ok ,now seriously that depends, how you plan to use your application(the client server part), if you plan to use it only for clients inside of the same time zone this my make sense but if your must book from Europe a hotel in Australia or back words from Japan in Europe you may encounter this "past book".


Regards M.
[ September 19, 2006: Message edited by: Mihai Radulescu ]
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That might work for client side validation, but not serverside.
If you have a dataformat the server can know about, the server should check for valid data before working with it.
Mind that this is no business logic anymore at that point, but purely based on the data making sense in the context of the type of data.
So if you're for example passing a string that should represent a date and the database knows it's supposed to be a date but stores it as a string (something the client need not know) the server should check whether that string can be converted to a date or not whether the client also does that or not (because it cannot know the client can be trusted).
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeep, Jeroen you are right on the server it must be performed an other validity check.

Regards M.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic