[Jifty-commit] r7690 - jifty/trunk/lib/Jifty

Jifty commits jifty-commit at lists.jifty.org
Wed Dec 2 06:16:41 EST 2009

Author: sartak
Date: Wed Dec  2 06:16:41 2009
New Revision: 7690


Document the new extra parameters these column methods get

Modified: jifty/trunk/lib/Jifty/Action.pm
--- jifty/trunk/lib/Jifty/Action.pm	(original)
+++ jifty/trunk/lib/Jifty/Action.pm	Wed Dec  2 06:16:41 2009
@@ -1312,16 +1312,20 @@
 the name of the field be normalized. Here is an example:
   sub canonicalize_foo {
-      my ($self, $value) = @_;
+      my ($self, $value, $other, $metadata) = @_;
       # do something to canonicalize the value
-      my $normal_form = lc($value);
+      my $normal_form = lc($value) . '-' . $other->{other_field};
+      $normal_form .= '-update' if $metadata->{for} eq 'update';
       return $normal_form;
-In this case, all values in the "foo" field will be changed into lower
+The first parameter to your canonicalizer will be the value to be
+canonicalized. The next will be a hash reference of all the parameters
+submitted with this canonicalization, so you can be smarter. Finally, the third
+parameter is a hash reference of other metadata, such as C<for>, whose value
+will be C<create> or C<update>.
 While doing this you might also want to call the
 L</canonicalization_note> to inform the client of the modification:
@@ -1344,7 +1348,7 @@
 the name of the field being checked. Here is an example:
   sub validate_foo {
-      my ($self, $value) = @_;
+      my ($self, $value, $other, $metadata) = @_;
       # Check for uppercase letters
       if ($value =~ /\p{Lu}/) {
@@ -1367,6 +1371,8 @@
 of your validation to the user or simply return 1 to indicate a valid
+Note that the parameters are the same as in L</Canonicalization>.
 If you just have a list of valid values, you may want to use the
 C<valid_values> schema parameter to perform this task instead.

More information about the Jifty-commit mailing list