.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "JSON::Validator::Formats 3pm" .TH JSON::Validator::Formats 3pm "2023-03-06" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" JSON::Validator::Formats \- Functions for validating JSON schema formats .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& use JSON::Validator::Formats; \& my $error = JSON::Validator::Formats::check_uri($str); \& die $error if $error; \& \& my $jv = JSON::Validator\->new; \& $jv\->formats({ \& "date\-time" => JSON::Validator::Formats\->can("check_date_time"), \& "email" => JSON::Validator::Formats\->can("check_email"), \& "hostname" => JSON::Validator::Formats\->can("check_hostname"), \& "ipv4" => JSON::Validator::Formats\->can("check_ipv4"), \& "ipv6" => JSON::Validator::Formats\->can("check_ipv6"), \& "regex" => JSON::Validator::Formats\->can("check_regex"), \& "uri" => JSON::Validator::Formats\->can("check_uri"), \& "uri\-reference" => JSON::Validator::Formats\->can("check_uri_reference"), \& }); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" JSON::Validator::Formats is a module with utility functions used by \&\*(L"formats\*(R" in JSON::Validator to match \s-1JSON\s0 Schema formats. All functions return \f(CW\*(C`undef\*(C'\fR for success or an error message for failure. .SH "FUNCTIONS" .IX Header "FUNCTIONS" .SS "check_byte" .IX Subsection "check_byte" .Vb 1 \& my $str_or_undef = check_byte $str; .Ve .PP Checks that the string matches byte format. .SS "check_date" .IX Subsection "check_date" .Vb 1 \& my $str_or_undef = check_date $str; .Ve .PP Validates the date part of a \s-1RFC3339\s0 string. .SS "check_date_time" .IX Subsection "check_date_time" .Vb 1 \& my $str_or_undef = check_date_time $str; .Ve .PP Validated against \s-1RFC3339\s0 timestamp in \s-1UTC\s0 time. This is formatted as \&\*(L"YYYY\-MM\-DDThh:mm:ss.fffZ\*(R". The milliseconds portion (\*(L".fff\*(R") is optional .SS "check_duration" .IX Subsection "check_duration" .Vb 1 \& my $str_or_undef = check_duration $str; .Ve .PP Validate a \s-1RFC3339\s0 duration string, such as \*(L"P3Y6M4DT12H30M5S\*(R". .SS "check_double" .IX Subsection "check_double" .Vb 1 \& my $str_or_undef = check_double $number; .Ve .PP Tries to check if the number is a double. Note that this check is not very accurate. .SS "check_email" .IX Subsection "check_email" .Vb 1 \& my $str_or_undef = check_email $str; .Ve .PP Validated against the \s-1RFC5322\s0 spec. .SS "check_float" .IX Subsection "check_float" .Vb 1 \& my $str_or_undef = check_float $number; .Ve .PP Tries to check if the number is a float. Note that this check is not very accurate. .SS "check_hostname" .IX Subsection "check_hostname" .Vb 1 \& my $str_or_undef = check_hostname $str; .Ve .PP Will be validated using \*(L"is_hostname\*(R" in Data::Validate::Domain, if installed. .SS "check_idn_email" .IX Subsection "check_idn_email" .Vb 1 \& my $str_or_undef = check_idn_email $str; .Ve .PP Will validate an email with non-ASCII characters using Net::IDN::Encode if installed. .SS "check_idn_hostname" .IX Subsection "check_idn_hostname" .Vb 1 \& my $str_or_undef = check_idn_hostname $str; .Ve .PP Will validate a hostname with non-ASCII characters using Net::IDN::Encode if installed. .SS "check_int32" .IX Subsection "check_int32" .Vb 1 \& my $str_or_undef = check_int32 $number; .Ve .PP Tries to check if the number is a int32. Note that this check is not very accurate. .SS "check_int64" .IX Subsection "check_int64" .Vb 1 \& my $str_or_undef = check_int64 $number; .Ve .PP Tries to check if the number is a int64. Note that this check is not very accurate. .SS "check_ipv4" .IX Subsection "check_ipv4" .Vb 1 \& my $str_or_undef = check_ipv4 $str; .Ve .PP Will be validated using \*(L"is_ipv4\*(R" in Data::Validate::IP, if installed or fall back to a plain IPv4 \s-1IP\s0 regex. .SS "check_ipv6" .IX Subsection "check_ipv6" .Vb 1 \& my $str_or_undef = check_ipv6 $str; .Ve .PP Will be validated using \*(L"is_ipv6\*(R" in Data::Validate::IP, if installed. .SS "check_iri" .IX Subsection "check_iri" .Vb 1 \& my $str_or_undef = check_iri $str; .Ve .PP Validate either an absolute \s-1IRI\s0 containing \s-1ASCII\s0 or non-ASCII characters, against the \s-1RFC3986\s0 spec. .SS "check_iri_reference" .IX Subsection "check_iri_reference" .Vb 1 \& my $str_or_undef = check_iri_reference $str; .Ve .PP Validate either a relative or absolute \s-1IRI\s0 containing \s-1ASCII\s0 or non-ASCII characters, against the \s-1RFC3986\s0 spec. .SS "check_json_pointer" .IX Subsection "check_json_pointer" .Vb 1 \& my $str_or_undef = check_json_pointer $str; .Ve .PP Validates a \s-1JSON\s0 pointer, such as \*(L"/foo/bar/42\*(R". .SS "check_regex" .IX Subsection "check_regex" .Vb 1 \& my $str_or_undef = check_regex $str; .Ve .PP Will check if the string is a regex, using \f(CW\*(C`qr{...}\*(C'\fR. .SS "check_relative_json_pointer" .IX Subsection "check_relative_json_pointer" .Vb 1 \& my $str_or_undef = check_relative_json_pointer $str; .Ve .PP Validates a relative \s-1JSON\s0 pointer, such as \*(L"0/foo\*(R" or \*(L"3#\*(R". .SS "check_time" .IX Subsection "check_time" .Vb 1 \& my $str_or_undef = check_time $str; .Ve .PP Validates the time and optionally the offset part of a \s-1RFC3339\s0 string. .SS "check_uri" .IX Subsection "check_uri" .Vb 1 \& my $str_or_undef = check_uri $str; .Ve .PP Validate either a relative or absolute \s-1URI\s0 containing just \s-1ASCII\s0 characters, against the \s-1RFC3986\s0 spec. .PP Note that this might change in the future to only check absolute \s-1URI.\s0 .SS "check_uri_reference" .IX Subsection "check_uri_reference" .Vb 1 \& my $str_or_undef = check_uri_reference $str; .Ve .PP Validate either a relative or absolute \s-1URI\s0 containing just \s-1ASCII\s0 characters, against the \s-1RFC3986\s0 spec. .SS "check_uri_template" .IX Subsection "check_uri_template" .Vb 1 \& my $str_or_undef = check_uri_reference $str; .Ve .PP Validate an absolute \s-1URI\s0 with template characters. .SS "check_uuid" .IX Subsection "check_uuid" .Vb 1 \& my $str_or_undef = check_uuid $str; .Ve .PP Will check if \f(CW$str\fR looks like an \s-1UUID.\s0 Example \s-1UUID: \&\*(L"5782165B\-6BB6\-472F\-B3DD\-369D707D6C72\*(R".\s0 .SH "SEE ALSO" .IX Header "SEE ALSO" JSON::Validator.