| 1 | # ABSTRACT: Backwards-Compatibility Layer for Validation::Class | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | package Validation::Class::Backwards; | ||||||||||||||||||||||||||||||||||||||||||
| 4 | { | ||||||||||||||||||||||||||||||||||||||||||
| 5 | 56 | $Validation::Class::Backwards::VERSION = '7.10_01'; | |||||||||||||||||||||||||||||||||||||||||
| 6 | } | ||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 56 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 56 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 56 | our $VERSION = '7.10_01'; # VERSION | |||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 56 | ▶ | use Carp 'confess'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 56 | $ENV{'VALIDATION_CLASS_BC_WARNING'} = <<'WARNING'; # usage warning | |||||||||||||||||||||||||||||||||||||||||
| 16 | The method you're attempting to use is (or will be) DEPRECIATED. | ||||||||||||||||||||||||||||||||||||||||||
| 17 | WARNING | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | sub warning { | ||||||||||||||||||||||||||||||||||||||||||
| 20 | warn $ENV{'VALIDATION_CLASS_BC_WARNING'} | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | if $ENV{'VALIDATION_CLASS_BC_WARNING'} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
warning: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub error { warning(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | # set an error message on a particular field | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | if ( @args == 2 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | # set error message | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | my ( $field, $error ) = @args; | |||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | # field must be a reference (hashref) to a field object | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | if ( ref($field) && ( !ref($error) && $error ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
ref $field and (not ref $error and $error)
not ref $error and $error
MC/DC0%0/3
ref $field and (not ref $error and $error)
ref $field
not ref $error
$error
Truth table0%0/4
A and not(B) and C
A= ref $fieldB= not ref $errorC= $error
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | # temporary, may break stuff | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | $error = $field->{error} if defined $field->{error}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | # add error to field-level errors | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | $field->{errors}->add($error); | |||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | # add error to class-level errors | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | $self->errors->add($error); | |||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | confess "Can't set error without proper field object, " | |||||||||||||||||||||||||||||||||||||||||
| 52 | . "field must be a hashref with name and value keys"; | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | # retrieve an error message on a particular field | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | if ( @args == 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | # add error to class-level errors | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | $self->errors->add($args[0]); | |||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | # return all class-level error messages | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | return $self->errors->all; | |||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 56 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 72 | __END__ | ||||||||||||||||||||||||||||||||||||||||||