Debian Codegraph @

t/lib/MyVocabulary/StringComparison.pm

raw
1 # vim: set ft=perl ts=8 sts=2 sw=2 tw=100 et :
2 package MyVocabulary::StringComparison;
3 use Moo;
4 use strictures 2;
5 use stable 0.031 'postderef';
6 use experimental 'signatures';
7 use if "$]" >= 5.022, experimental => 're_strict';
8 no if "$]" >= 5.031009, feature => 'indirect';
9 no if "$]" >= 5.033001, feature => 'multidimensional';
10 no if "$]" >= 5.033006, feature => 'bareword_filehandles';
11 no if "$]" >= 5.041009, feature => 'smartmatch';
12 no feature 'switch';
13 with 'JSON::Schema::Modern::Vocabulary';
14
15 use JSON::Schema::Modern::Utilities qw(assert_keyword_type is_type E);
16
17 sub vocabulary {
18 'https://vocabulary/string/comparison' => 'draft2020-12',
19 }
20
21 sub keywords { 'stringLessThan' }
22
23 sub _traverse_keyword_stringLessThan ($self, $schema, $state) {
24 return if not assert_keyword_type($state, $schema, 'string');
25 return 1;
26 }
27
28 sub _eval_keyword_stringLessThan ($self, $data, $schema, $state) {
29 return 1 if not is_type('string', $data);
30 return 1 if ($data cmp $schema->{stringLessThan}) == -1;
31 return E($state, 'value is not stringwise less than %s', $schema->{stringLessThan});
32 }
33
34 1;