NAME
JSON::Schema::Types - Create Type::Tiny types defined by JSON Schemas
VERSION
version 0.001
SYNOPSIS
use JSON::Schema::Types ':all';
my $my_type = json_schema_type({
type => 'object',
properties => {
foo => { type => 'integer' },
bar => { type => 'string' },
}
});
my $second_type = JSON::Schema::Types->new(
validate_formats => 0,
schema => false,
);
# prints 'data is valid'
say 'data is ', $my_type->check({ foo => 1, bar => 'hello' }) ? 'valid' : 'invalid';
# prints 'data is invalid'
say 'data is ', $second_type->check(1) ? 'valid' : 'invalid' ? 'valid' : 'invalid';
DESCRIPTION
Generates Type::Tiny types for you that use a JSON Schema to validate the data.
FUNCTIONS/METHODS
json_schema_type
Creates a type value for you using the provided schema. No custom behaviour is available.
new
Creates a type value for you, with customization options. Options available are:
schema: Required. Contains the JSON Schema to use.
max_traversal_depth: Optional. more later.
scalarref_booleans: Optional. more later.
short_circuit: Optional. Whenever possible, each subschema will end evaluation as soon as a true or false result can be determined. When enabled, This obviously does not affect the overall valid/invalid result, but the error list will be incomplete.
specification_version: Optional. Defaults to the latest release version of the JSON Schema specification, currently
draft2020-12
.stringy_numbers: Optional. more later.
validate_formats: Optional. Enables or disables format validation. Defaults to
true
.
SEE ALSO
Understanding JSON Schema: tutorial-focused documentation
SUPPORT
Bugs may be submitted through https://github.com/karenetheridge/JSON-Schema-Types/issues.
I am also usually active on irc, as 'ether' at irc.perl.org
and irc.libera.chat
.
AUTHOR
Karen Etheridge <ether@cpan.org>
COPYRIGHT AND LICENCE
This software is copyright (c) 2025 by Karen Etheridge.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.