around 'create_child_type' => sub {
my ($create_child_type, $self, %opts) = @_;
+ if($self->has_constraining_value) {
+ $opts{constraining_value} = $self->constraining_value;
+ }
return $self->$create_child_type(
%opts,
parent=> $self,
around 'check' => sub {
my ($check, $self, @args) = @_;
- if($self->has_constraining_value) {
- push @args, $self->constraining_value;
- }
return $self->parent_type_constraint->check(@args) && $self->$check(@args)
};
around 'validate' => sub {
my ($validate, $self, @args) = @_;
- if($self->has_constraining_value) {
- push @args, $self->constraining_value;
- }
return $self->parent_type_constraint->validate(@args) || $self->$validate(@args);
};
+around '_compiled_type_constraint' => sub {
+ my ($method, $self, @args) = @_;
+ my $coderef = $self->$method(@args);
+ my @extra_args = $self->has_constraining_value ? $self->constraining_value : ();
+ return sub {
+ my @local_args = @_;
+ $coderef->(@local_args, @extra_args);
+ };
+};
+
=head2 get_message
Give you a better peek into what's causing the error.