From Code to Community: Sponsoring The Perl and Raku Conference 2025 Learn more

NAME

Class::Workflow::Transition::Validate - Provide a hook for validating a transition (conditionals, input validators, etc).

SYNOPSIS

package MyTransition;
use Moose;
with qw/
Class::Workflow::Transition::Validate
/;
sub validate {
my ( $self, $instance, %args ) = @_;
die "only the owner can apply this transition"
unless $args{user} eq $instance->owner;
}

DESCRIPTION

This role will call the validate method at the appropriate time.

validate receives the same arguments as apply, and is expected to die if any of the parameters for the transition are invalid.

Technically, this role doesn't do much more than adding syntactic sugar for before 'apply'. However, it's value is in the convention that you can call validate without applying the body. This eases writing side effect free introspection of transitions.