JSON::V...Formats(3)

๐Ÿ’– NAME ๐Ÿ’–

okay so bestie, welcome to the JSON::Validator::Formats(3) manual page โ€” User Contributed Perl Documentation energy, no cap. It's literally all about Functions for validating JSON schema formats. That's the whole name vibe. Periodt. ๐Ÿ’…

โœจ SYNOPSIS โœจ

Here's the exact group-chat starter pack, copy-paste ready:

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"),
});

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

JSON::Validator::Formats is a module packed with utility functions used by "formats" in JSON::Validator to match JSON Schema formats. Cute, iconic, useful. All functions return undef for success or an error message for failure โ€” so bestie, watch for that error string. ๐Ÿ’…

๐ŸŽ€ FUNCTIONS ๐ŸŽ€

check_byte

my $str_or_undef = check_byte $str;

Checks that the string matches byte format. That's the vibe check, slay. โœจ

check_date

my $str_or_undef = check_date $str;

Validates the date part of a RFC3339 string. Just the date part, bestie. ๐Ÿ“…

check_date_time

my $str_or_undef = check_date_time $str;

Validated against RFC3339 timestamp in UTC time. This is formatted as "YYYY-MM-DDThh:mm:ss.fffZ". The milliseconds portion (".fff") is optional. The optional millis are giving tiny-detail main character energy. โฐ

check_duration

my $str_or_undef = check_duration $str;

Validate a RFC3339 duration string, such as "P3Y6M4DT12H30M5S". Duration slay. โณ

check_double

my $str_or_undef = check_double $number;

Tries to check if the number is a double. Note that this check is not very accurate. Lowkey not the most precise vibe check, so don't expect miracles. ๐Ÿ’€

check_email

my $str_or_undef = check_email $str;

Validated against the RFC5322 spec. Email icon behavior. ๐Ÿ“ง

check_float

my $str_or_undef = check_float $number;

Tries to check if the number is a float. Note that this check is not very accurate. Same caveat, same energy. ๐Ÿซถ

check_hostname

my $str_or_undef = check_hostname $str;

Will be validated using "is_hostname" in Data::Validate::Domain, if installed. Bestie, that "if installed" is doing real work. ๐Ÿ’…

check_idn_email

my $str_or_undef = check_idn_email $str;

Will validate an email with non-ASCII characters using Net::IDN::Encode if installed. International email icon. ๐ŸŒ

check_idn_hostname

my $str_or_undef = check_idn_hostname $str;

Will validate a hostname with non-ASCII characters using Net::IDN::Encode if installed. Same requirement, same icon. ๐Ÿฆ‹

check_int32

my $str_or_undef = check_int32 $number;

Tries to check if the number is an int32. Note that this check is not very accurate. Don't come for it, it's doing its best. ๐Ÿ˜ญ

check_int64

my $str_or_undef = check_int64 $number;

Tries to check if the number is an int64. Note that this check is not very accurate. Same accuracy situation. ๐Ÿ’€

check_ipv4

my $str_or_undef = check_ipv4 $str;

Will be validated using "is_ipv4" in Data::Validate::IP, if installed or fall back to a plain IPv4 IP regex. Fallback icon. ๐Ÿ”ฅ

check_ipv6

my $str_or_undef = check_ipv6 $str;

Will be validated using "is_ipv6" in Data::Validate::IP, if installed. No fallback mentioned here, bestie. ๐ŸŒˆ

check_iri

my $str_or_undef = check_iri $str;

Validate either an absolute IRI containing ASCII or non-ASCII characters, against the RFC3986 spec. IRI with range. ๐Ÿ‘‘

check_iri_reference

my $str_or_undef = check_iri_reference $str;

Validate either a relative or absolute IRI containing ASCII or non-ASCII characters, against the RFC3986 spec. Relative-or-absolute icon. ๐Ÿงš

check_json_pointer

my $str_or_undef = check_json_pointer $str;

Validates a JSON pointer, such as "/foo/bar/42". Pointer bestie. ๐Ÿ“

check_regex

my $str_or_undef = check_regex $str;

Will check if the string is a regex, using "qr{...}". Regex slay. ๐ŸŽ€

check_relative_json_pointer

my $str_or_undef = check_relative_json_pointer $str;

Validates a relative JSON pointer, such as "0/foo" or "3#". Relative pointer icon. โœจ

check_time

my $str_or_undef = check_time $str;

Validates the time and optionally the offset part of a RFC3339 string. Optional offset is optional, iykyk. โฐ

check_uri

my $str_or_undef = check_uri $str;

Validate either a relative or absolute URI containing just ASCII characters, against the RFC3986 spec.

Note that this might change in the future to only check absolute URI. That's a future vibe, fr fr. ๐Ÿ”ฎ

check_uri_reference

my $str_or_undef = check_uri_reference $str;

Validate either a relative or absolute URI containing just ASCII characters, against the RFC3986 spec. Same URI reference energy. ๐Ÿ’œ

check_uri_template

my $str_or_undef = check_uri_reference $str;

Validate an absolute URI with template characters. And yes, the signature line printed here is exactly check_uri_reference โ€” we're keeping it character-for-character, no cap. ๐Ÿ’…

check_uuid

my $str_or_undef = check_uuid $str;

Will check if $str looks like an UUID. Example UUID: "5782165B-6BB6-472F-B3DD-369D707D6C72". UUID slay. ๐Ÿ”ฅ

๐ŸŒˆ SEE ALSO ๐ŸŒˆ

JSON::Validator.


That's the whole page, bestie. It's from perl v5.42.0, dated 2025-03-17, and it's giving User Contributed Perl Documentation realness. Mwah ๐Ÿ’œ

๐Ÿ“ฆ where this page comes from