]> Dogcows Code - chaz/p5-CGI-Ex/blobdiff - samples/devel/dprof_validation.d
CGI::Ex 2.00
[chaz/p5-CGI-Ex] / samples / devel / dprof_validation.d
diff --git a/samples/devel/dprof_validation.d b/samples/devel/dprof_validation.d
new file mode 100644 (file)
index 0000000..5b02305
--- /dev/null
@@ -0,0 +1,41 @@
+# -*-perl-*-
+# run with perl -d:DProf $0
+
+use CGI::Ex::Validate;
+
+my $form = {
+  username  => "++foobar++",
+  password  => "123",
+  password2 => "1234",
+};
+
+my $val_hash_ce = {
+    username => {
+        required => 1,
+        match    => 'm/^\w+$/',
+        match_error => '$name may only contain letters and numbers',
+        untaint  => 1,
+    },
+    password => {
+        required => 1,
+        min_len  => 6,
+        max_len  => 30,
+        match    => 'm/^[ -~]+$/',
+        untaint  => 1,
+    },
+    password2 => {
+        validate_if => 'password',
+        equals      => 'password',
+    },
+    email => {
+        required => 1,
+        match    => 'm/^[\w\.\-]+\@[\w\.\-]+$/',
+        untaint  => 1,
+    },
+};
+
+
+for (1 .. 10_000) {
+    my $err_obj = CGI::Ex::Validate->validate($form, $val_hash_ce);
+#    my $err_obj = CGI::Ex::Validate->validate($form, $val_hash_ce)->as_hash;
+}
This page took 0.021287 seconds and 4 git commands to generate.