Mandatory Custom Field

To all,

We have a Custom Field called "Need-By Date". It is applied to only a 

few Queues. In order to ensure the format entered is consistent, I put
the following “(?#Date)^\d{2}/\d{2}/\d{4}$” into the Validation field.
The result is RT demands an entry as though it is a Mandatory Field. I
only wanted the format to be mandatory so that IF it was entered, it
would require the desired format. Any ideas on how to accomplish this?
Thanks ahead of time.

Kenn
LBNL

At Monday 3/10/2008 12:31 PM, Kenneth Crocker wrote:

To all,

    We have a Custom Field called "Need-By Date". It is applied 

to only a
few Queues. In order to ensure the format entered is consistent, I put
the following “(?#Date)^\d{2}/\d{2}/\d{4}$” into the Validation field.
The result is RT demands an entry as though it is a Mandatory Field. I
only wanted the format to be mandatory so that IF it was entered, it
would require the desired format. Any ideas on how to accomplish this?
Thanks ahead of time.

Kenn
LBNL

Kenn,

Here’s what we have for an optional date field (MM/DD/YY format):

‘(?#Date-Optional
MM/DD/YY)^(((0)?[1-9]|1[0-2])/((0)?[1-9]|[12][0-9]|3[01])/([12][0-9])?[0-9][0-9])?$’,

It’s the final ‘?’ that makes this optional - without it, the field
is mandatory.

Steve

Stephen Turner
Senior Programmer/Analyst - SAIS
MIT Information Services and Technology (IS&T)

Stephen,

Why does yours have so much code? I just tried adding the '?' at the 

end, in front of the ‘$’ and it still doesn’t work. Where would I make a
change to yours in order to get 4 positions for year?

Kenn
LBNLOn 3/10/2008 11:06 AM, Stephen Turner wrote:

At Monday 3/10/2008 12:31 PM, Kenneth Crocker wrote:

To all,

    We have a Custom Field called "Need-By Date". It is applied to 

only a
few Queues. In order to ensure the format entered is consistent, I put
the following “(?#Date)^\d{2}/\d{2}/\d{4}$” into the Validation field.
The result is RT demands an entry as though it is a Mandatory Field. I
only wanted the format to be mandatory so that IF it was entered, it
would require the desired format. Any ideas on how to accomplish this?
Thanks ahead of time.

Kenn
LBNL

Kenn,

Here’s what we have for an optional date field (MM/DD/YY format):

‘(?#Date-Optional
MM/DD/YY)^(((0)?[1-9]|1[0-2])/((0)?[1-9]|[12][0-9]|3[01])/([12][0-9])?[0-9][0-9])?$’,

It’s the final ‘?’ that makes this optional - without it, the field is
mandatory.

Steve

Stephen Turner
Senior Programmer/Analyst - SAIS
MIT Information Services and Technology (IS&T)

At Monday 3/10/2008 05:10 PM, Kenneth Crocker wrote:

Stephen,

    Why does yours have so much code? I just tried adding the 

‘?’ at the end, in front of the ‘$’ and it still doesn’t work.
Where would I make a change to yours in order to get 4 positions for year?

Kenn
LBNL

Kenn,

Our version does more checking on entered values that yours- the one
you posted would allow something like 66/43/76 as a valid date.
Looking at ours a bit more closely, it may actually allow a 4-digit
year, although it also allows a 2-digit year. The year specification
is the last part - ([12][0-9])?[0-9][0-9] - I’m not a regexpert, but
I’d guess that removing the ? from the middle of that piece would
enforce a 4-digit year. The parentheses in that part are also
probably not needed if you remove the ?.

If you want to extend your version to make it optional, try using parentheses:

(?#Date)^(\d{2}/\d{2}/\d{4})?$

Steve>On 3/10/2008 11:06 AM, Stephen Turner wrote:

At Monday 3/10/2008 12:31 PM, Kenneth Crocker wrote:

To all,

    We have a Custom Field called "Need-By Date". It is 

applied to only a
few Queues. In order to ensure the format entered is consistent, I put
the following “(?#Date)^\d{2}/\d{2}/\d{4}$” into the Validation field.
The result is RT demands an entry as though it is a Mandatory Field. I
only wanted the format to be mandatory so that IF it was entered, it
would require the desired format. Any ideas on how to accomplish this?
Thanks ahead of time.

Kenn
LBNL
Kenn,
Here’s what we have for an optional date field (MM/DD/YY format):
‘(?#Date-Optional
MM/DD/YY)^(((0)?[1-9]|1[0-2])/((0)?[1-9]|[12][0-9]|3[01])/([12][0-9])?[0-9][0-9])?$’,

It’s the final ‘?’ that makes this optional - without it, the field
is mandatory.
Steve

Stephen Turner
Senior Programmer/Analyst - SAIS
MIT Information Services and Technology (IS&T)

Stephen Turner
Senior Programmer/Analyst - SAIS
MIT Information Services and Technology (IS&T)

Stephen & Steve,

Thanks a bunch, really. I'm just now learning some perl, so a lot of 

stuff confuses me. I think I see it, so double thanks. You helped me fix
a problem AND taught me something.

Kenn
LBNLOn 3/11/2008 6:19 AM, Stephen Turner wrote:

At Monday 3/10/2008 05:10 PM, Kenneth Crocker wrote:

Stephen,

    Why does yours have so much code? I just tried adding the '?' 

at the end, in front of the ‘$’ and it still doesn’t work. Where would
I make a change to yours in order to get 4 positions for year?

Kenn
LBNL

Kenn,

Our version does more checking on entered values that yours- the one you
posted would allow something like 66/43/76 as a valid date. Looking at
ours a bit more closely, it may actually allow a 4-digit year, although
it also allows a 2-digit year. The year specification is the last part -
([12][0-9])?[0-9][0-9] - I’m not a regexpert, but I’d guess that
removing the ? from the middle of that piece would enforce a 4-digit
year. The parentheses in that part are also probably not needed if you
remove the ?.

If you want to extend your version to make it optional, try using
parentheses:

(?#Date)^(\d{2}/\d{2}/\d{4})?$

Steve

On 3/10/2008 11:06 AM, Stephen Turner wrote:

At Monday 3/10/2008 12:31 PM, Kenneth Crocker wrote:

To all,

    We have a Custom Field called "Need-By Date". It is applied 

to only a
few Queues. In order to ensure the format entered is consistent, I put
the following “(?#Date)^\d{2}/\d{2}/\d{4}$” into the Validation field.
The result is RT demands an entry as though it is a Mandatory Field. I
only wanted the format to be mandatory so that IF it was entered, it
would require the desired format. Any ideas on how to accomplish this?
Thanks ahead of time.

Kenn
LBNL
Kenn,
Here’s what we have for an optional date field (MM/DD/YY format):
‘(?#Date-Optional
MM/DD/YY)^(((0)?[1-9]|1[0-2])/((0)?[1-9]|[12][0-9]|3[01])/([12][0-9])?[0-9][0-9])?$’,

It’s the final ‘?’ that makes this optional - without it, the field
is mandatory.
Steve

Stephen Turner
Senior Programmer/Analyst - SAIS
MIT Information Services and Technology (IS&T)

Stephen Turner
Senior Programmer/Analyst - SAIS
MIT Information Services and Technology (IS&T)

Stephen & Steve,

Thanks a bunch, really. I’m just now learning some perl, so a lot of
stuff confuses me. I think I see it, so double thanks. You helped me fix
a problem AND taught me something.

This provides a useful head start into regular expressions:

http://www.matthewgifford.com/a-tao-of-regular-expressions/

If you are going to go deep into regex, with or without perl, pick up
“Mastering Regular Expressions”, by Jeffrey Fried.

http://regex.info/

Regular Expressions have been useful for soooooo many things, once I
understood them. The better I understand them, the more useful they
become. Mr. Fried’s book, in it’s first revision at least, was very
easy to read.

Scott Lambert KC5MLE Unix SysAdmin
lambert@lambertfam.org

Scott,

Very good. I'll get it.

Kenn
LBNLOn 3/11/2008 10:39 AM, Scott Lambert wrote:

On Tue, Mar 11, 2008 at 09:05:09AM -0700, Kenneth Crocker wrote:

Stephen & Steve,

Thanks a bunch, really. I’m just now learning some perl, so a lot of
stuff confuses me. I think I see it, so double thanks. You helped me fix
a problem AND taught me something.

This provides a useful head start into regular expressions:

http://www.matthewgifford.com/a-tao-of-regular-expressions/

If you are going to go deep into regex, with or without perl, pick up
“Mastering Regular Expressions”, by Jeffrey Fried.

http://regex.info/

Regular Expressions have been useful for soooooo many things, once I
understood them. The better I understand them, the more useful they
become. Mr. Fried’s book, in it’s first revision at least, was very
easy to read.