Gossamer Forum
Home : Products : DBMan : Installation :

newbie question about 'default' and 'valid_expr'

Quote Reply
newbie question about 'default' and 'valid_expr'
Okay, my newbie question for the day.

In the instruction text under "3.2 Defining your darabase" there are 2 fields 'default' and 'valid_expr'. With the descriptions of:

default = you can enter a value to use as a default. Call &get_date to insert today's date
valid_expr = enter a regular expression to validate input

In the "db.cfg Definition of your database" they occur again. Example:

%db_def = (
Id =>[0,'numer', 5, 8, 1, " "]
Validated =>[7, 'alpha', 0, 3, 1, 'Yes', 'Yes/No']

I must be really stupid because I can't fugure out for the life of me what these last 2 positions do ..... ie: the areas after the 1. Could somebody please tell me 1.) dahh, you're right that you're a newbie and 2.) Explain in more detail what I'm just not getting.

I've really have been trying to figure this stuff out but I'm not making the connections.

Sorry :-( but I would really appreciate the help :-)

Jdunes

------------------
Thanks for everything !
Quote Reply
Re: newbie question about 'default' and 'valid_expr' In reply to
Yep, you're a newbie! Smile

That's okay. All of us were newbies at one time or another.

The "default" part of the field definition is whatever you would like to be filled in the field before anybody enters anything. For example, since all URLs have "http://" in them, it's reasonable to fill in the field with that to start with. Most users will leave it in there, but forget to add it if it's not there in the first place.

In the example you cited from the demo, Alex set the "Validated" field to be "Yes" automatically.

For most things, you can leave it blank and just use the two single quotes -- '' -- in that position.

The "valid_expr" is a little more complicated, but not too much. This is what is allowed to be in the field. Again using the URL as an example, you would probably want to be sure that any URL actually did start with "http://" -- that the user didn't delete the info you so graciously supplied. The ^ at the beginning of the http:// means that the field must start with those characters. If it doesn't the user will receive an error message when he tries to add a record.

In the example you cite, "'Yes/No'", it's actually 'Yes|No'. A pipe character between the two words means that either 'Yes' or 'No' is an acceptable response in that field. If there is anything else in the field, the user will get an error message.

The ^ and the | are part of "regular expressions" in Perl. There are entire books (well, one at least) on the writing of regular expressions. Usually you don't have to worry about them, though. It is pretty rare when you have to limit the user to a certain format for entries in a field.

If you should need to write a regular expression for the last part of a field definition and need some help writing it, be sure to ask. I'm sure that someone here will be able to help. (I don't know if it will be me, though. I'm still a little fuzzy on regular expressions too! Smile )

I hope this helps.



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