Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

rename validate to assert_valid for clarity

  • Loading branch information...
commit a23ae0fec54cfcc8837600752f6727ec23aa5684 1 parent 90185f6
@rjbs authored
View
4 perl/lib/Data/Rx/CoreType.pm
@@ -22,7 +22,7 @@ sub check {
my ($self, $value) = @_;
local $@;
- return 1 if eval { $self->validate($value); };
+ return 1 if eval { $self->assert_valid($value); };
my $failures = $@;
if (eval { $failures->isa('Data::Rx::Failures') }) {
@@ -76,7 +76,7 @@ sub _subchecks {
my ($value, $checker, $context) = @$subcheck;
- next if eval { $checker->validate($value) };
+ next if eval { $checker->assert_valid($value) };
my $failures = $@;
Carp::confess($failures)
View
2  perl/lib/Data/Rx/CoreType/all.pm
@@ -26,7 +26,7 @@ sub new_checker {
return $self;
}
-sub validate {
+sub assert_valid {
my ($self, $value) = @_;
my @subchecks;
View
4 perl/lib/Data/Rx/CoreType/any.pm
@@ -24,7 +24,7 @@ sub new_checker {
return $self;
}
-sub validate {
+sub assert_valid {
return 1 unless $_[0]->{of};
my ($self, $value) = @_;
@@ -32,7 +32,7 @@ sub validate {
my @failures;
for my $i (0 .. $#{ $self->{of} }) {
my $check = $self->{of}[ $i ];
- return 1 if eval { $check->validate($value) };
+ return 1 if eval { $check->assert_valid($value) };
my $failure = $@;
$failure->contextualize({
View
2  perl/lib/Data/Rx/CoreType/arr.pm
@@ -32,7 +32,7 @@ sub new_checker {
return $self;
}
-sub validate {
+sub assert_valid {
my ($self, $value) = @_;
unless (! Scalar::Util::blessed($value) and ref $value eq 'ARRAY') {
View
2  perl/lib/Data/Rx/CoreType/bool.pm
@@ -4,7 +4,7 @@ package Data::Rx::CoreType::bool;
use base 'Data::Rx::CoreType';
# ABSTRACT: the Rx //bool type
-sub validate {
+sub assert_valid {
my ($self, $value) = @_;
return 1 if (
View
2  perl/lib/Data/Rx/CoreType/def.pm
@@ -4,7 +4,7 @@ package Data::Rx::CoreType::def;
use base 'Data::Rx::CoreType';
# ABSTRACT: the Rx //def type
-sub validate {
+sub assert_valid {
my ($self, $value) = @_;
return 1 if defined $value;
View
2  perl/lib/Data/Rx/CoreType/fail.pm
@@ -4,7 +4,7 @@ package Data::Rx::CoreType::fail;
use base 'Data::Rx::CoreType';
# ABSTRACT: the Rx //fail type
-sub validate {
+sub assert_valid {
$_[0]->fail({
error => [ qw(fail) ],
message => "matching reached an always-fail check",
View
2  perl/lib/Data/Rx/CoreType/map.pm
@@ -23,7 +23,7 @@ sub new_checker {
return $self;
}
-sub validate {
+sub assert_valid {
my ($self, $value) = @_;
unless (! Scalar::Util::blessed($value) and ref $value eq 'HASH') {
View
2  perl/lib/Data/Rx/CoreType/nil.pm
@@ -4,7 +4,7 @@ package Data::Rx::CoreType::nil;
use base 'Data::Rx::CoreType';
# ABSTRACT: the Rx //nil type
-sub validate {
+sub assert_valid {
my ($self, $value) = @_;
return 1 if ! defined $value;
View
2  perl/lib/Data/Rx/CoreType/num.pm
@@ -64,7 +64,7 @@ sub _value_is_of_type {
return $value =~ $_NUM_RE;
}
-sub validate {
+sub assert_valid {
my ($self, $value) = @_;
$self->__type_fail($value) unless defined $value and length $value;
View
2  perl/lib/Data/Rx/CoreType/one.pm
@@ -4,7 +4,7 @@ package Data::Rx::CoreType::one;
use base 'Data::Rx::CoreType';
# ABSTRACT: the Rx //one type
-sub validate {
+sub assert_valid {
my ($self, $value) = @_;
if (! defined $value) {
View
2  perl/lib/Data/Rx/CoreType/rec.pm
@@ -42,7 +42,7 @@ sub new_checker {
return $self;
}
-sub validate {
+sub assert_valid {
my ($self, $value) = @_;
unless (! Scalar::Util::blessed($value) and ref $value eq 'HASH') {
View
2  perl/lib/Data/Rx/CoreType/seq.pm
@@ -31,7 +31,7 @@ sub new_checker {
return $self;
}
-sub validate {
+sub assert_valid {
my ($self, $value) = @_;
unless (! Scalar::Util::blessed($value) and ref $value eq 'ARRAY') {
View
2  perl/lib/Data/Rx/CoreType/str.pm
@@ -36,7 +36,7 @@ sub new_checker {
return $self;
}
-sub validate {
+sub assert_valid {
my ($self, $value) = @_;
unless (defined $value) {
View
4 perl/t/lib/Test/RxTester.pm
@@ -83,7 +83,7 @@ sub assert_pass {
my $desc = "$schema_desc should ACCEPT $input_desc";
try {
- $schema->validate($input);
+ $schema->assert_valid($input);
Test::More::pass("$desc");
} catch {
my $fails = $_;
@@ -102,7 +102,7 @@ sub assert_fail {
my $desc = "$schema_desc should REJECT $input_desc";
try {
- $schema->validate($input);
+ $schema->assert_valid($input);
Test::More::fail($desc);
if ($want_struct) {
Test::More::fail("$desc, failures struct");
View
5 sf-demo.pl
@@ -1,6 +1,7 @@
#!perl
use strict;
use warnings;
+use 5.10.1;
use lib 'perl/lib';
use Data::Rx;
@@ -43,7 +44,7 @@
},
];
-eval { $schema->validate($input); };
+eval { $schema->assert_valid($input); };
my $fail = $@;
-print $fail;
+say $fail;
Please sign in to comment.
Something went wrong with that request. Please try again.