[open-ils-commits] r16556 - trunk/Open-ILS/src/perlmods/OpenILS/Utils (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Jun 2 10:55:25 EDT 2010
Author: miker
Date: 2010-06-02 10:55:23 -0400 (Wed, 02 Jun 2010)
New Revision: 16556
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Utils/Fieldmapper.pm
Log:
add class/instance methods for checking required-ness and validity of an object field in perl FM implementation; also fixing typo
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Utils/Fieldmapper.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Utils/Fieldmapper.pm 2010-06-02 14:38:58 UTC (rev 16555)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Utils/Fieldmapper.pm 2010-06-02 14:55:23 UTC (rev 16556)
@@ -93,7 +93,7 @@
position => $array_position,
};
- $$fieldmap{$fm}{fields}{ $name }{validate} = qr/$valudate/ if (defined($validate));
+ $$fieldmap{$fm}{fields}{ $name }{validate} = qr/$validate/ if (defined($validate));
# The selector attribute, if present at all, attaches to only one
# of the fields in a given class. So if we see it, we store it at
@@ -312,6 +312,21 @@
return $$fieldmap{$self->class_name}{controller};
}
+sub RequiredField {
+ my $self = shift;
+ my $f = shift;
+ return undef unless ($f);
+ return $$fieldmap{$self->class_name}{fields}{$f}{required};
+}
+
+sub ValidateField {
+ my $self = shift;
+ my $f = shift;
+ return undef unless ($f);
+ return 1 if (!exists($$fieldmap{$self->class_name}{fields}{$f}{validate}));
+ return $self->$f =~ $$fieldmap{$self->class_name}{fields}{$f}{validate};
+}
+
sub class_name {
my $class_name = shift;
return ref($class_name) || $class_name;
More information about the open-ils-commits
mailing list