| 1 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | package HTML::FormFu::Constraint::JSON; | ||||||||||||||||||||||||||||
| 4 | 2 | $HTML::FormFu::Constraint::JSON::VERSION = '2.06'; | |||||||||||||||||||||||||||
| 5 | 2 | ▶ | use JSON::MaybeXS qw( decode_json ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 2 | extends 'HTML::FormFu::Constraint'; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | sub constrain_value { | ||||||||||||||||||||||||||||
| 11 | 4 | ▶ | my ( $self, $value ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
constrain_value: called CC=4 SCAR=15.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 4 | ▶ | return 1 if !defined $value || $value eq ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $value or $value eq ""
MC/DC0%0/2
not defined $value or $value eq ""
not defined $value
$value eq ""
Truth table33%1/3
not(A) or B
A= not defined $valueB= $value eq ""
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 4 | my $ok = decode_json($value); | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 2 | ▶ | return $self->not ? !$ok : $ok; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 2 | 1; | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | __END__ | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | =pod | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | =head1 NAME | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | HTML::FormFu::Constraint::JSON | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | =head1 VERSION | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | version 2.06 | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | Checks for valid JSON string | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | =head1 NAME | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | HTML::FormFu::Constraint::JSON - Valid JSON string | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | Is a sub-class of, and inherits methods from L<HTML::FormFu::Constraint> | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | L<HTML::FormFu> | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | Carl Franks C<cfranks@cpan.org> | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | =head1 LICENSE | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | This library is free software, you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 59 | the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | Carl Franks <cpan@fireartist.com> | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | This software is copyright (c) 2018 by Carl Franks. | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 70 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | =cut | ||||||||||||||||||||||||||||