Skip to content

'needs' is too specific; we need a more flexible test #6

Open

Description

What we have now is effectively "needs all". What about "needs only one" or "needs any"?

Possibly take a sub reference and let people use Syntax::Keyword::Junction:

use Syntax::Keyword::Junction qw/any one/;

my $spec = [
    Param("foo")->needs( sub { $_ eq any(qw/bar baz/) } ),
    Param("baz")->needs( sub { $_ eq one(qw/quux wibble/) } ),
];

Or, possibly we just make those individual methods (and use junctions internally):

my $spec = [
    Param("foo")->needs_any(qw/bar baz/),
    Param("baz")->needs_one(qw/quux wibble/),
];

Activity

  1. bitbugprime commented on Mar 27, 2013

    @bitbugprime

    How about adding "excludes" (or something similar) as well?

    Param("foo")->excludes("bar")
    

    means that if foo is specified, bar may not also be specified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions