• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

URLyBird 1.3.3: Validation of currency on the rate field

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ravikiran Vishnuvajhala
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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'm so happy! And I wish to make this tiny ad happy too:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic