File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes URLyBird 1.3.3: Validation of currency on the rate field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "URLyBird 1.3.3: Validation of currency on the rate field" Watch "URLyBird 1.3.3: Validation of currency on the rate field" New topic
Author

URLyBird 1.3.3: Validation of currency on the rate field

Ravikiran Vishnuvajhala
Ranch Hand

Joined: Jan 11, 2006
Posts: 30
Hi,

I have a field that contains the currency symbol and the amount for the room. The following is the instruction statement from SUN -


I am debating about the following points regarding the validation of currency on the "rate" field. Please execuse me if some of them are pretty basic questions -

1. How many bytes should I allocate for the currency symbol? Can I assume one byte?
2. How will I validate the float/double value after the symbol? Also, can the symbol be the last character in the field value?

3. Depending on the currency, it could have a "." or a "," as the decimal symbol.
4. How many digits can be present after the decimal?

Do you think there is a easy way to validate these or I leaning towards not doing the validation at all and just document it that when data class is directly invoked, users need to enter a valid value?

Or can I make some choices here like - one byte for currency and digits after decimals can be only two and the decimal separtor symbol can be only "." and that the currency symbol should be at the beginning of the field?

Or if there is a way to validate all these, please do let me know.

Thanks
Ravi

[ March 25, 2007: Message edited by: Ravikiran Vishnuvajhala ]

[ March 25, 2007: Message edited by: Ravikiran Vishnuvajhala ]

[ March 25, 2007: Message edited by: Ravikiran Vishnuvajhala ]
[ March 25, 2007: Message edited by: Ravikiran Vishnuvajhala ]
chris bajada
Ranch Hand

Joined: Oct 16, 2006
Posts: 41
What do you need the currency symbol for? As far as i know there is no calculation to be done with the prices, thus we can treat all prices as strings with no validation whatsoever
Ravikiran Vishnuvajhala
Ranch Hand

Joined: Jan 11, 2006
Posts: 30
Well, if someone is calling the create,update methods directly on the Data class, they can send garbage like "$abc.123", "$123.abc" or "$123,abc" right. Don't we need to prevent that?
Lucy Hummel
Ranch Hand

Joined: Apr 07, 2005
Posts: 232
Hi Ravi,

This week the parsing/checking of the concurrency was already discussed and I think
Li made a good point why and when to check the symbol.

Br, Lucy


----------------------------------<br />| SCJP, SCWCD, SCBCD, SCEA, SCJD |<br />----------------------------------
Ravikiran Vishnuvajhala
Ranch Hand

Joined: Jan 11, 2006
Posts: 30
After thinking more about it and from what you people mentioned, I also now think what you people are saying does make sense. This field cannot be manipulated in any way other than users directly accessing the Data Class to enter some useless data. Then, I guess it is their problem.

Thanks a lot for your suggestions and inputs.

Thanks
Ravi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: URLyBird 1.3.3: Validation of currency on the rate field