Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^3: Type::Tiny and anyOf, oneOf

by tobyink (Canon)
on Feb 04, 2021 at 21:54 UTC ( #11127899=note: print w/replies, xml ) Need Help??


in reply to Re^2: Type::Tiny and anyOf, oneOf
in thread Type::Tiny and anyOf, oneOf

Something like this:

my $type = Dict->of( foo => Str, baz => Optional[Int], qux => Optional[Str], )->where(q{ exists $_->{baz} or exists $_->{qux} }); if ( $type->check( \%somehash ) ) { say "matched"; }

Also, might be worth looking into JSON-Schema-AsType.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11127899]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (None)
    As of 2021-10-16 23:42 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      My first memorable Perl project was:







      Results (70 votes). Check out past polls.

      Notices?