HTML::Widget::Constraint::Callback - Callback Constraint


HTML-Widget documentation Contained in the HTML-Widget distribution.

Index


Code Index:

NAME

Top

HTML::Widget::Constraint::Callback - Callback Constraint

SYNOPSIS

Top

    my $c = $widget->constraint( 'Callback', 'foo' )->callback(sub { 
        my $value=shift;
        return 1;
    });

DESCRIPTION

Top

A callback constraint which will only be run once for each submitted value of each named field.

METHODS

Top

callback

cb

Arguments: \&callback

Define the callback to be used for validation.

cb is an alias for callback.

validate

perform the actual validation.

AUTHOR

Top

Sebastian Riedel, sri@oook.de

Marcus Ramberg, mramberg@cpan.org

LICENSE

Top

This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.


HTML-Widget documentation Contained in the HTML-Widget distribution.
package HTML::Widget::Constraint::Callback;

use warnings;
use strict;
use base 'HTML::Widget::Constraint';

__PACKAGE__->mk_accessors(qw/callback/);

*cb = \&callback;

sub validate {
    my ( $self, $value ) = @_;
    my $callback = $self->callback || sub {1};
    return $callback->($value);
}

1;