Apache-Voodoo
view release on metacpan or search on metacpan
lib/Apache/Voodoo/Table.pm view on Meta::CPAN
253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
# if there wasn't a successful add, then there's no details :)
return
unless
$self
->{
'success'
};
return
$self
->{
'add_details'
} || [];
}
sub
add_insert_callback {
my
$self
=
shift
;
my
$sub_ref
=
shift
;
push
(@{
$self
->{
'insert_callbacks'
}},
$sub_ref
);
}
sub
add_update_callback {
my
$self
=
shift
;
my
$sub_ref
=
shift
;
push
(@{
$self
->{
'update_callbacks'
}},
$sub_ref
);
}
sub
list_param_parser {
my
$self
=
shift
;
my
$sub_ref
=
shift
;
$self
->{
'list_param_parser'
} =
$sub_ref
;
}
sub
validate_add {
my
$self
=
shift
;
my
$p
=
shift
;
my
$dbh
=
$p
->{
'dbh'
};
my
$params
=
$p
->{
'params'
};
my
$errors
= {};
# call each of the insert callbacks
foreach
(@{
$self
->{
'insert_callbacks'
}}) {
my
$callback_errors
=
$_
->(
$dbh
,
$params
);
@{
$errors
}{
keys
%{
$callback_errors
}} =
values
%{
$callback_errors
};
}
# do all the normal parameter checking
my
(
$values
,
$e
) =
$self
->{valid}->validate(
$params
);
# copy the errors from the process_params
$errors
= { %{
$errors
}, %{
$e
} }
if
ref
(
$e
) eq
"HASH"
;
lib/Apache/Voodoo/Table.pm view on Meta::CPAN
338339340341342343344345346347348349350351352353354355356357358359my
$p
=
shift
;
my
$dbh
=
$p
->{
'dbh'
};
my
$params
=
$p
->{
'params'
};
unless
(
$params
->{
$self
->{
'pkey'
}} =~ /
$self
->{
'pkey_regexp'
}/) {
return
$self
->display_error(
"Invalid ID"
);
}
my
$errors
= {};
# call each of the update callbacks
foreach
(@{
$self
->{
'update_callbacks'
}}) {
# call back should return a list of error strings
my
$callback_errors
=
$_
->(
$dbh
,
$params
);
@{
$errors
}{
keys
%{
$callback_errors
}} =
values
%{
$callback_errors
};
}
# run the standard error checks
my
(
$values
,
$e
) =
$self
->{valid}->validate(
$params
);
# copy the errors from the process_params
$errors
= { %{
$errors
}, %{
$e
} }
if
ref
(
$e
) eq
"HASH"
;
lib/Apache/Voodoo/Validate.pm view on Meta::CPAN
303132333435363738394041424344454647484950
my
$sub_ref
=
shift
;
#unless (defined($context)) {
# Apache::Vodooo::Exception::RunTime->throw("add_callback requires a context name as the first parameter");
#}
unless
(
ref
(
$sub_ref
) eq
"CODE"
) {
Apache::Vodooo::Exception::RunTime::BadConfig->throw(
"add_callback requires a subroutine reference as the second paramter"
);
}
#push(@{$self->{'callbacks'}->{$context}},$sub_ref);
$self
->{
'vc'
} =
$sub_ref
;
}
sub
set_error_formatter {
my
$self
=
shift
;
my
$sub_ref
=
shift
;
if
(
ref
(
$sub_ref
) eq
"CODE"
) {
$self
->{
'ef'
} =
$sub_ref
;
}
( run in 0.328 second using v1.01-cache-2.11-cpan-5f2e87ce722 )