Skip Menu |

This queue is for tickets about the Type-Tiny CPAN distribution.

Report information
The Basics
Id: 102638
Status: rejected
Priority: 0/
Queue: Type-Tiny

People
Owner: Nobody in particular
Requestors: ZDM [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: "Default" type constraint for using with Dict and Tuple
Hi. Maybe it will be useful to add "Default" constraint. Dict [ aaa => Default [Num, 10], bbb => Default [20], ] It should check if key exists, and if exists - validate value type, if type constraint present. If key not exists - create key with default value. And the same for Tuple. I can prepare patch request, if you do not mind.
Type constraints don't (and shouldn't) alter the values they check. Could possibly be done with type coercions though. I'd *consider* accepting an implementation of this. The whole point of Type::Library though, is that you can publish your own libraries of constraints and coercions — they don't need to be built into Type::Tiny.
Subject: Re: [rt.cpan.org #102638] "Default" type constraint for using with Dict and Tuple
Date: Tue, 7 Feb 2017 00:09:26 +0200
To: bug-Type-Tiny [...] rt.cpan.org
From: "dzagashev [...] gmail.com" <dzagashev [...] gmail.com>
yes, I am agree. On 06.02.2017 23:33, Toby Inkster via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=102638 > > > Type constraints don't (and shouldn't) alter the values they check. Could possibly be done with type coercions though. > > I'd *consider* accepting an implementation of this. The whole point of Type::Library though, is that you can publish your own libraries of constraints and coercions — they don't need to be built into Type::Tiny. >