Class::Workflow::Transition::Validate - Provide a hook for validating a transition (conditionals, input validators, etc).
package MyTransition; use Moose; with qw/ Class::Workflow::Transition Class::Workflow::Transition::Validate /; sub validate { my ( $self, $instance, %args ) = @_; die "only the owner can apply this transition" unless $args{user} eq $instance->owner; }
This role will call the validate method at the appropriate time.
validate
validate receives the same arguments as apply, and is expected to die if any of the parameters for the transition are invalid.
apply
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.
before 'apply'
To install Class::Workflow, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::Workflow
CPAN shell
perl -MCPAN -e shell install Class::Workflow
For more information on module installation, please visit the detailed CPAN module installation guide.