ValidateCustomFields

Send rt-users mailing list submissions to
rt-users@lists.bestpractical.com

To subscribe or unsubscribe via the World Wide Web, visit
The rt-users Archives
or, via email, send a message with subject or body ‘help’ to
rt-users-request@lists.bestpractical.com

You can reach the person managing the list at
rt-users-owner@lists.bestpractical.com

When replying, please edit your Subject line so it is more specific
than “Re: Contents of rt-users digest…”

Today’s Topics:

1. Friendly Validation Errors? (Mike Kennedy)
2. Re: Size of the database. (Darin Perusich)
3. RT-Authen-ExternalAuth. (Julien CAUNAN)
4. Re: Size of the database. (Albert Shih)

Message: 1
Date: Mon, 22 Oct 2012 03:27:45 +0000
From: Mike Kennedymichael.kennedy@ucr.edu
To: “”
rt-users@lists.bestpractical.com
Subject: [rt-users] Friendly Validation Errors?
Message-ID:
4377A360F69D024197AF65862DEBCC051FE0C5B1@EXCH-MBOX-1.exch.ucr.edu
Content-Type: text/plain; charset=“us-ascii”

Hello,

I’ve searched the archives, Google, the wiki (so I’m sorry if the answer to this is there, but I just missed it.)

Is there any way, short of editing the source, to have more friendly validation errors. So, rather than “Input must match [Mandatory]” I could change it to say “This field is required.” Or, instead of “Input must match [1]+$”, it could say, “Value must contain only letters.”

Thanks,

Mike

Hello Mike,

you can change /Elements/ValidateCustomFields in a plugin like that that.
The code is like that:

my %Messages = (“[Mandatory]” => “This field is required”,
“[[2]+]” => “This field must contain letters”);

foreach my $value( @values ) {
next if $CF->MatchPattern($value);
my $msg = exists($Messages{$CF->FriendlyPattern})
?$Messages{$CF->FriendlyPattern} :“Input must match”.$CF->FriendlyPattern ;
$m->notes( (‘InvalidField-’ . $CF->Id) => $msg );
push @res, $msg;
$valid = 0;
}

That does work.


  1. a-zA-Z ↩︎

  2. a-zA-Z ↩︎