File: load-yaml.t

package info (click to toggle)
libjson-validator-perl 4.14%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 828 kB
  • sloc: perl: 2,816; makefile: 14
file content (33 lines) | stat: -rw-r--r-- 728 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use Mojo::Base -strict;
use JSON::Validator;
use Test::More;

my $jv     = JSON::Validator->new;
my @errors = $jv->schema('data://Some::Module/s_pec-/-ficaTion')->validate({firstName => 'yikes!'});

is int(@errors), 1, 'one error';
is $errors[0]->path,    '/lastName',         'lastName';
is $errors[0]->message, 'Missing property.', 'required';
is_deeply $errors[0]->TO_JSON, {path => '/lastName', message => 'Missing property.'}, 'TO_JSON';

done_testing;

package Some::Module;
__DATA__
@@ s_pec-/-ficaTion

---
title: Example Schema
type: object
required:
  - firstName
  - lastName
properties:
  firstName:
    type: string
  lastName:
    type: string
  age:
    type: integer
    minimum: 0
    description: Age in years