Index: t/TestApp/t/06-validation.t =================================================================== --- t/TestApp/t/06-validation.t (revision 4800) +++ t/TestApp/t/06-validation.t (working copy) @@ -5,7 +5,7 @@ use lib 't/lib'; use Jifty::SubTest; -use Jifty::Test tests => 22; +use Jifty::Test tests => 27; use Jifty::Test::WWW::Mechanize; my $server = Jifty::Test->make_server; @@ -56,6 +56,15 @@ "Getting validator.xml output for a form entry"); $mech->content_lacks('', " ... validator didn't return error for bar"); +$mech->get_ok("$URL/__jifty/validator.xml?J:A-canontest=TestApp::Action::CreateCanonTest&J:A:F-column_1-canontest=f-f&J:VALIDATE=1", + "Getting validator.xml output for a form entry to check canonicalize_"); +$mech->content_contains('ff'); + +$mech->get_ok("$URL/__jifty/validator.xml?J:A-canontest=TestApp::Action::CreateCanonTest&J:A:F-column_1-canontest=;f&J:VALIDATE=1", + "Getting validator.xml output for a form entry to check canonicalize_"); +$mech->content_lacks('content_contains('f'); + TODO: { local $TODO = "Not implemented in Jifty yet"; $mech->content_contains('You need to fill in this field', " ... validator returned error for foo"); Index: t/TestApp/lib/TestApp/Model/CanonTest.pm =================================================================== --- t/TestApp/lib/TestApp/Model/CanonTest.pm (revision 0) +++ t/TestApp/lib/TestApp/Model/CanonTest.pm (revision 0) @@ -0,0 +1,21 @@ +use strict; +use warnings; + +package TestApp::Model::CanonTest; +use Jifty::DBI::Schema; + +use TestApp::Record schema { + column column_1 => type is 'text'; +}; + +# we want to drop all non-word chars + +sub canonicalize_column_1 { + my $self = shift; + my $value = shift; + $value =~ s/\W//g; + return $value; +} + +1; +