mateu / moox-types-mooselike Goto Github PK
View Code? Open in Web Editor NEWTypes for Moo that are common to Moose
Types for Moo that are common to Moose
MooX/Types/MooseLike.pm, line 52
A new $test coderef is declared, which handles type check both for parent-type and subtype. Initial shift in this coderef is stored in $value and passed to test functions, both parent and child. The problem is when you have a type that has a subtype_of field and uses a parameter. The parameter will then never get passed to the test function, making it impossible to implement any type with a parameter that is a subtype of something.
When using parameterized types, suddenly Moo's "required" check doesn't work anymore.
Sample code follows.
This errors out correctly:
{
package MyObject;
use Moo;
use MooX::Types::MooseLike::Base qw<HashRef>;
has attr => ( is => "ro", isa => HashRef, required => 1 );
}
MyObject->new();
# Missing required arguments: attr at (eval 19) line 31.
This, however, doesn't crash at all.
{
package MyObject;
use Moo;
use MooX::Types::MooseLike::Base qw<HashRef>;
has attr => ( is => "ro", isa => HashRef[HashRef], required => 1 ); # <- here is the change
}
MyObject->new();
The Str
type isn't validated for undef
so it is accepted. It shouldn't.
This is what happens when you try to give undef
to an Str
type in Moose:
Validation failed for 'Str' with value undef
Moose::Util::TypeConstraints has enum(\@values)
function to support.
Does this module have a plan to support replacement for this style type?
The code:
Num->(undef)
Yields the following error:
Use of uninitialized value $_[0] in concatenation (.) or string at /home/sawyer/perl5/lib/perl5/MooX/Types/MooseLike/Base.pm line 64.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.