| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Schema::Validator; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
157563
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
30
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
48
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
467
|
use JSON::MaybeXS qw(decode_json encode_json); |
|
|
1
|
|
|
|
|
11050
|
|
|
|
1
|
|
|
|
|
72
|
|
|
7
|
1
|
|
|
1
|
|
929
|
use LWP::UserAgent; |
|
|
1
|
|
|
|
|
56558
|
|
|
|
1
|
|
|
|
|
46
|
|
|
8
|
1
|
|
|
1
|
|
628
|
use Encode qw(decode); |
|
|
1
|
|
|
|
|
20650
|
|
|
|
1
|
|
|
|
|
114
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
8
|
use base 'Exporter'; # Use Exporter as the base class |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
937
|
|
|
11
|
|
|
|
|
|
|
our @EXPORT_OK = qw(is_valid_datetime load_dynamic_vocabulary); |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our %dynamic_properties; # Global variable to store property definitions |
|
16
|
|
|
|
|
|
|
our %dynamic_schema; # Global variable to store class definitions |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 NAME |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Schema::Validator - Tools for validating and loading Schema.org vocabulary definitions |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 VERSION |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Version 0.02 |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 FROM THE COMMAND LINE |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
bin/validate-schema --file index.html |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 FROM PERL |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
use Schema::Validator qw(is_valid_datetime load_dynamic_vocabulary); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# Validate datetime strings |
|
37
|
|
|
|
|
|
|
if (is_valid_datetime('2024-11-14')) { |
|
38
|
|
|
|
|
|
|
print "Valid date\n"; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
if (is_valid_datetime('2024-11-14T15:30:00')) { |
|
42
|
|
|
|
|
|
|
print "Valid datetime\n"; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# Load Schema.org vocabulary |
|
46
|
|
|
|
|
|
|
my %schema = load_dynamic_vocabulary(); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Access loaded schema definitions |
|
49
|
|
|
|
|
|
|
print 'Classes: ', scalar(keys %Schema::Validator::dynamic_schema), "\n"; |
|
50
|
|
|
|
|
|
|
print 'Properties: ', scalar(keys %Schema::Validator::dynamic_properties), "\n"; |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Schema::Validator provides utilities for working with Schema.org structured data vocabularies. |
|
55
|
|
|
|
|
|
|
It includes functions for validating datetime formats and dynamically loading Schema.org class |
|
56
|
|
|
|
|
|
|
and property definitions from the official Schema.org JSON-LD vocabulary file. |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 Command Line Schema.org Validator |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
This repository contains a Schema.org validator that scans HTML files for embedded JSON-LD (`application/ld+json` blocks) and validates them against a local schema definition. |
|
61
|
|
|
|
|
|
|
It can optionally output diagnostics in SARIF format for GitHub Code Scanning integration. |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
The Validator is a versatile tool designed to help you validate structured data embedded in your HTML files. |
|
64
|
|
|
|
|
|
|
At its core, the script parses HTML to extract |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|