.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Kwalify 3pm" .TH Kwalify 3pm "2022-11-11" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Kwalify \- Kwalify schema for data structures .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& use Kwalify qw(validate); \& validate($schema, $data); .Ve .PP Typically used together with \s-1YAML\s0 or \s-1JSON:\s0 .PP .Vb 2 \& use YAML; \& validate(YAML::LoadFile($schema_file), YAML::LoadFile($data_file)); \& \& use JSON; \& validate(decode_json($schema_data), decode_json($data)); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Kwalify is a Perl implementation for validating data structures against the Kwalify schema. For a schema definition, see , but see also below \*(L"\s-1SCHEMA DEFINITION\*(R"\s0. .ie n .SS "validate($schema_data, $data)" .el .SS "validate($schema_data, \f(CW$data\fP)" .IX Subsection "validate($schema_data, $data)" Validate \fI\f(CI$data\fI\fR according to Kwalify schema specified in \&\fI\f(CI$schema_data\fI\fR. Dies if the validation fails. .PP \&\fBvalidate\fR may be exported. .SH "SCHEMA DEFINITION" .IX Header "SCHEMA DEFINITION" The original schema definition document is not very specific about types and behaviour. Here's how \fBKwalify.pm\fR implements things: .IP "pattern" 4 .IX Item "pattern" Perl regular expressions are used for patterns. This may or may not be compatible with other Kwalify validators, so restrict to \*(L"simple\*(R" regular expression constructs to be compatible with other validators. .IP "type" 4 .IX Item "type" .RS 4 .PD 0 .IP "str" 4 .IX Item "str" .PD Any defined value which is \fBnot\fR a number. Most probably you will want to use \fBtext\fR instead of \fBstr\fR. .IP "int" 4 .IX Item "int" A possibly signed integer. Note that scientific notation is not supported, and it is also not clear whether it should be supported. .IP "float" 4 .IX Item "float" A possibly signed floating value with a mandatory decimal point. Note that scientific notation is also not supported here. .IP "bool" 4 .IX Item "bool" The values \fByes\fR, \fBtrue\fR, and \fB1\fR for true values and the values \&\fBno\fR, \fBfalse\fR, and \fB0\fR for false values are allowed. The ruby implementation possibly allows more values, but this is not documented. .Sp Note that this definition is problematic, because for example the string \fBno\fR is a true boolean value in Perl. So one should stick to \&\fB0\fR and \fB1\fR as data values, and probably define an additional \&\fBpattern\fR or \fBenum\fR to ensure this: .Sp .Vb 2 \& type: bool \& enum: [0, 1] .Ve .IP "scalar" 4 .IX Item "scalar" Currently the same as \fBtext\fR, but it's not clear if this is correct. .IP "date" 4 .IX Item "date" A string matching \f(CW\*(C`/^\ed{4}\-\ed{2}\-\ed{2}$/\*(C'\fR (i.e. YYYY-MM-DD). Note that no date range checks are done (yet). .IP "time" 4 .IX Item "time" A string matching \f(CW\*(C`/^\ed{2}:\ed{2}:\ed{2}$/\*(C'\fR (i.e. \s-1HH:MM:SS\s0). Note that no time range checks are done (yet). .IP "timestamp" 4 .IX Item "timestamp" Not supported \-\-\- it is not clear what this is supposed to be. .RE .RS 4 .RE .IP "assert" 4 .IX Item "assert" Currently not supported by the Perl implementation. .IP "classname" 4 .IX Item "classname" Previously defined what is now \fBclass\fR, see . .IP "class" 4 .IX Item "class" Currently not used, as there's no genclass action. .IP "default" 4 .IX Item "default" Currently not used, as there's no genclass action. .SH "TECHNICAL NOTES" .IX Header "TECHNICAL NOTES" As \fBKwalify.pm\fR is a pure validator and de-coupled from a parser (in fact, it does not need to deal with \s-1YAML\s0 at all, but just with pure perl data structures), there's no connection to the original validated document. This means that no line numbers are available to the validator. In case of validation errors the validator is only able to show a path-like expression to the data causing the error. .SH "AUTHOR" .IX Header "AUTHOR" Slaven Rezić, .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright (C) 2006,2007,2008,2009,2010,2015 by Slaven Rezić .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .SH "SEE ALSO" .IX Header "SEE ALSO" pkwalify, \fBkwalify\fR\|(1). .PP Other non-XML schema languages: