1JSON::Validator::FormatUss(e3r)Contributed Perl DocumentJaStOiNo:n:Validator::Formats(3)
2
3
4

NAME

6       JSON::Validator::Formats - Functions for validating JSON schema formats
7

SYNOPSIS

9         use JSON::Validator::Formats;
10         my $error = JSON::Validator::Formats::check_uri($str);
11         die $error if $error;
12
13         my $jv = JSON::Validator->new;
14         $jv->formats({
15           "date-time"     => JSON::Validator::Formats->can("check_date_time"),
16           "email"         => JSON::Validator::Formats->can("check_email"),
17           "hostname"      => JSON::Validator::Formats->can("check_hostname"),
18           "ipv4"          => JSON::Validator::Formats->can("check_ipv4"),
19           "ipv6"          => JSON::Validator::Formats->can("check_ipv6"),
20           "regex"         => JSON::Validator::Formats->can("check_regex"),
21           "uri"           => JSON::Validator::Formats->can("check_uri"),
22           "uri-reference" => JSON::Validator::Formats->can("check_uri_reference"),
23         });
24

DESCRIPTION

26       JSON::Validator::Formats is a module with utility functions used by
27       "formats" in JSON::Validator to match JSON Schema formats.  All
28       functions return "undef" for success or an error message for failure.
29

FUNCTIONS

31   check_date
32         my $str_or_undef = check_date $str;
33
34       Validates the date part of a RFC3339 string.
35
36   check_date_time
37         my $str_or_undef = check_date_time $str;
38
39       Validated against RFC3339 timestamp in UTC time. This is formatted as
40       "YYYY-MM-DDThh:mm:ss.fffZ". The milliseconds portion (".fff") is
41       optional
42
43   check_email
44         my $str_or_undef = check_email $str;
45
46       Validated against the RFC5322 spec.
47
48   check_hostname
49         my $str_or_undef = check_hostname $str;
50
51       Will be validated using "is_hostname" in Data::Validate::Domain, if
52       installed.
53
54   check_idn_email
55         my $str_or_undef = check_idn_email $str;
56
57       Will validate an email with non-ASCII characters using Net::IDN::Encode
58       if installed.
59
60   check_idn_hostname
61         my $str_or_undef = check_idn_hostname $str;
62
63       Will validate a hostname with non-ASCII characters using
64       Net::IDN::Encode if installed.
65
66   check_ipv4
67         my $str_or_undef = check_ipv4 $str;
68
69       Will be validated using "is_ipv4" in Data::Validate::IP, if installed
70       or fall back to a plain IPv4 IP regex.
71
72   check_ipv6
73         my $str_or_undef = check_ipv6 $str;
74
75       Will be validated using "is_ipv6" in Data::Validate::IP, if installed.
76
77   check_iri
78         my $str_or_undef = check_iri $str;
79
80       Validate either an absolute IRI containing ASCII or non-ASCII
81       characters, against the RFC3986 spec.
82
83   check_iri_reference
84         my $str_or_undef = check_iri_reference $str;
85
86       Validate either a relative or absolute IRI containing ASCII or non-
87       ASCII characters, against the RFC3986 spec.
88
89   check_json_pointer
90         my $str_or_undef = check_json_pointer $str;
91
92       Validates a JSON pointer, such as "/foo/bar/42".
93
94   check_regex
95         my $str_or_undef = check_regex $str;
96
97       Will check if the string is a regex, using "qr{...}".
98
99   check_relative_json_pointer
100         my $str_or_undef = check_relative_json_pointer $str;
101
102       Validates a relative JSON pointer, such as "0/foo" or "3#".
103
104   check_time
105         my $str_or_undef = check_time $str;
106
107       Validates the time and optionally the offset part of a RFC3339 string.
108
109   check_uri
110         my $str_or_undef = check_uri $str;
111
112       Validate either a relative or absolute URI containing just ASCII
113       characters, against the RFC3986 spec.
114
115       Note that this might change in the future to only check absolute URI.
116
117   check_uri_reference
118         my $str_or_undef = check_uri_reference $str;
119
120       Validate either a relative or absolute URI containing just ASCII
121       characters, against the RFC3986 spec.
122
123   check_uri_template
124         my $str_or_undef = check_uri_reference $str;
125
126       Validate an absolute URI with template characters.
127

SEE ALSO

129       JSON::Validator.
130
131
132
133perl v5.30.1                      2020-02-09       JSON::Validator::Formats(3)
Impressum