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