If I have a method that takes either one or the other of two named parameters, exactly one of which must be present, is there a way to handle that with Params::Validate?
$store->put( content_ref => $stringref );
or
$store->put( path => $path_to_file );
I’m not seeing it in the docs, but it seems like an obvious use case, so I thought I should ask.
You can use
callbacksto achieve something along those lines:Output:
--- - path - some path --- - content_ref - !!perl/ref =: some content The 'content_ref' parameter ("SCALAR(0xab83cc)") to My::Class::put did not pass the 'Provided only if no 'path' is given' callback at C:\temp\v.pl line 37 My::Class::put(undef, 'path', 'another_path', 'content_ref', 'SCALAR(0xab83cc)') called at C:\temp\v.pl line 47