In Catalyst is there a way to specify that the sub accepts 0-n arguments, say 0-1? so that an action could be something like this:
sub add :Local :Args(#between 0 and 1) {
my ($self, $c) = @_;
#catalyst code
}
I know that something like this could probably be solved with regex somehow, but I was wondering if there was a way to do it by specifying it using the Args action modifier? Thanks!
Unless you’re chaining another action from this one, you can drop the
:Argscompletely and test yourself whether an argument was provided. From the documentation: