Gossamer Forum
Home : Products : DBMan : Customization :

validation of data types

Quote Reply
validation of data types
Hi,
Can DbMan validate data types when a user edits a record?
Quote Reply
Re: validation of data types In reply to
In the database definition section of the .cfg file the second configuration option specifies the data type, 'numer', 'alpha' or 'date'. 'numer' is numeric, 'alpha' is alphabetic and 'date' is... well, date. So just set the hours field to 'numer'.

'Tis in the docs me man!

Quote:
field_type = one of 'numer', 'alpha', 'date' depending on whether the information is numerical, alphabetical or a date.

Smile

Cheers,
adam
Quote Reply
Re: validation of data types In reply to
What do you want to do? A little more explanation please.


------------------
JPD





Quote Reply
Re: validation of data types In reply to
...well I'm trying to setup a little online database where employes can fill in their dayly log: number of hours worked and a short desription of what they did during the day.

If I put a field for the number of hours, I want people to enter a numerical value and nothing else. Is their any way of controling that with DBMan?
Quote Reply
Re: validation of data types In reply to
Not exactly, adam. The data type for the field determines how data will be sorted, but does not do any error-checking.

luc, you can set the "valid reg. expr." to do pretty much what you want.

If you set the valid reg. expr. to ^[\d]{0,2}\.{0,1}[\d]{0,2}$, it will allow 0-2 digits at the beginning, 0-1 decimal points in the middle, and 0-2 digits at the end.




------------------
JPD





Quote Reply
Re: validation of data types In reply to
*shamed*

Sorry luc, and thanks for pointing it out Carol!

adam

[This message has been edited by dahamsta (edited April 24, 1999).]
Quote Reply
Re: validation of data types In reply to
Dredging up an old topic... What is the best way to set the valid regular expression to allow a string of only numbers?

For example, a field can be anywhere from 1 to 6 digits, numerical only. I have the valid_expr field defined as ^[\d]{1,6}. This disallows an entry such as a1234, but does not catch 1a234. Setting a check for each position would be a problem, as there's no way of knowing how many digits will be in the number.

I should probably follow Pugdog's advice and get a regular expressions book...

Dan
Quote Reply
Re: validation of data types In reply to
Hi Dan, if I read Carol's instructions correctly . . .
Quote:
If you set the valid reg. expr. to ^[\d]{0,2}\.{0,1}[\d]{0,2}$, it will allow 0-2 digits at the beginning, 0-1 decimal points in the middle, and 0-2 digits at the end.

it seems she has said ^[\d]{0,10}$, would allow for up to 10 digits to be entered into the field. A bit of experimenting with it may give you the solution - I'm not a perl guru by any stretch of the imagination [is it a surprise to read something like that on these boards?] so I'm not sure on the $, at the end, required or not, but I think the digits portion is accurate from the details Carol had posted.




------------------
~ ~ ~ ~ ~
Karen

Quote Reply
Re: validation of data types In reply to
This is an old post....so it's kinda far in my memory but I do rembeber that JPDeni's answer was the solution......
Quote Reply
Re: validation of data types In reply to
^ = beginning of line when not in brackets
$ = end of line

The problem with ^\d{1,6} is that 1A (or even 1A2345) does indeed meet the beginning of line + interval requirement (a minimum of one number)... adding the dollar at the end should do the trick...

------------------
The Immuatable Order of Modding
-=-=-=-=-=-=-=-
1. Read the FAQ, 2. Search the board, 2a. Search the board again, 3. ask the question, 4. back-up, 5. experiment, 6. rephrase question (or better yet, post solution to original question)
Quote Reply
Re: validation of data types In reply to
Thanks, the $ is the key! So, does that mean everything between ^ and $ must follow the rules contained within, as opposed to just the first character following the first rule?

Dan
Quote Reply
Re: validation of data types In reply to
Not exactly, but for this example close enough... there are any number of different ways to constuct a regular expression. And like Perl, there is no *correct* way... if you are at all serious about customizing your code/site, learn a little a regex. Over 80% of the mods I do involve regex in some way...

------------------
The Immuatable Order of Modding
-=-=-=-=-=-=-=-
1. Read the FAQ, 2. Search the board, 2a. Search the board again, 3. ask the question, 4. back-up, 5. experiment, 6. rephrase question (or better yet, post solution to original question)