docs for ::Validate

This commit is contained in:
Yanick Champoux 2022-07-25 12:02:24 -04:00
parent ec4fee9e69
commit 92d3e10756
2 changed files with 19 additions and 11 deletions

View File

@ -3,13 +3,19 @@ package App::Changelord::Command::Validate;
use 5.36.0; use 5.36.0;
use Moo; use Moo;
use CLI::Osprey; use CLI::Osprey
doc => 'validate the changelog yaml',
description_pod => <<'END';
Validate the changelog against the JSON Schema used by changelord.
END
use Path::Tiny; use Path::Tiny;
use JSON; use JSON;
use YAML::XS; use YAML::XS;
use JSON::Schema::Modern; use JSON::Schema::Modern;
with 'App::Changelord::Role::Changelog';
option json => ( option json => (
is => 'ro', is => 'ro',
default => 0, default => 0,
@ -24,7 +30,7 @@ sub run($self) {
my $result = JSON::Schema::Modern->new( my $result = JSON::Schema::Modern->new(
output_format => 'detailed', output_format => 'detailed',
)->evaluate( )->evaluate(
$self->parent_command->changelog, $self->changelog,
YAML::XS::Load($schema), YAML::XS::Load($schema),
); );

View File

@ -42,12 +42,14 @@ properties:
- type: object - type: object
additionalProperties: false additionalProperties: false
properties: properties:
version: { type: string } version: { type: [ 'null', string ] }
date: { type: ['null',string] } date: { type: ['null',string] }
changes: { type: 'array', items: { $ref: '#/$defs/change' } } changes: { type: 'array', items: { $ref: '#/$defs/change' } }
$defs: $defs:
change: change:
type: object oneOf:
- type: string
- type: object
required: [ desc ] required: [ desc ]
additionalProperties: false additionalProperties: false
properties: properties: