Kwalify(3pm)
π Kwalify π
okay so bestie, this is Kwalify β the Perl manual page for validating your data structures against a Kwalify schema. it's giving "your data, but make it β¨accountableβ¨". (the manual name is Kwalify(3pm), in case you were wondering, and yes it's a perl module page π«Ά)
π SYNOPSIS π
use Kwalify qw(validate);
validate($schema, $data);
typically you'd use it with YAML or JSON, like:
use YAML;
validate(YAML::LoadFile($schema_file), YAML::LoadFile($data_file));
use JSON;
validate(decode_json($schema_data), decode_json($data));
β¨ DESCRIPTION β¨
Kwalify is a Perl implementation for validating data structures against the Kwalify schema. for an actual schema definition, go look at <https://web.archive.org/web/20190718083758/http://www.kuwata-lab.com/kwalify/ruby/users-guide.01.html>, but also, like, scroll down to "SCHEMA DEFINITION" below, because we got you π
validate($schema_data, $data)
this validates $data according to the Kwalify schema specified in $schema_data. it dies if the validation fails. no cap. π
validate may be exported.
π SCHEMA DEFINITION π
fr fr, the original schema definition document is not very specific about types and behaviour. here's how Kwalify.pm actually implements things:
nameβ the name of the schema.descβ the description for the rule. it is not used for validation, it's just there for vibes.patternβ a pattern matching the valid values. Perl regular expressions are used for patterns. this may or may not be compatible with other Kwalify validators, so if you want to be compatible with other validators, restrict yourself to "simple" regular expression constructs. π¬enumβ a list of the valid values.rangeβ a hash with the valid value ranges for types other thanseq,map,boolandany.maxβ the maximum inclusive.minβ the minimum inclusive.max-exβ the maximum exclusive.min-exβ the minimum exclusive.
lengthβ likerangebut forstrandtext.requiredβ a constraint to denote the value is required when true. the default is false.typeβ the default type if omitted isstr.strβ any defined value which is not a number. most probably you will want to usetextinstead ofstr.intβ a possibly signed integer. note that scientific notation is not supported, and it is also not clear whether it should be supported.floatβ a possibly signed floating value with a mandatory decimal point. note that scientific notation is also not supported here.numberβ a possibly signed floating value with an optional decimal point (so eitherintorfloat). note that scientific notation is also not supported here.textβ any defined value which is either astror a number.boolβ the valuesyes,true, and1for true values and the valuesno,false, and0for false values are allowed. the ruby implementation possibly allows more values, but this is not documented.
β οΈ note that this definition is problematic, because for example the stringnois a true boolean value in Perl. so one should stick to0and1as data values, and probably define an additionalpatternorenumto ensure this:
type: bool
enum: [0, 1]
dateβ a string matching"/^\d{4}-\d{2}-\d{2}$/"(i.e.YYYY-MM-DD). note that no date range checks are done (yet).timeβ a string matching"/^\d{2}:\d{2}:\d{2}$/"(i.e.HH:MM:SS). note that no time range checks are done (yet).timestampβ not supported --- it is not clear what this is supposed to be. πseqβ a sequence (list) of rules.mapβ a mapping (hash) of rules.
the name "=" can be used to apply rules to any key. π
scalarβ currently the same astext, but it's not clear if this is correct. originally defined as all butseqandmap.anyβ any data type.
uniqueβ the value is unique for aseqor amap.assertβ currently not supported by the Perl implementation. πclassnameβ previously defined what is nowclass, see<https://web.archive.org/web/20190718083758/http://www.kuwata-lab.com/kwalify/ruby/users-guide.01.html>.classβ currently not used, as there's nogenclassaction.defaultβ currently not used, as there's nogenclassaction.
π§ TECHNICAL NOTES π§
so as Kwalify.pm is a pure validator and de-coupled from a parser (in fact, it does not need to deal with YAML 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. it's giving β¨mysteryβ¨ but honestly it's the most it can do π
π AUTHOR π
Slaven ReziΔ, <srezic@cpan.org>
π COPYRIGHT AND LICENSE π
Copyright (C) 2006,2007,2008,2009,2010,2015 by Slaven ReziΔ
this library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
π¦ SEE ALSO π¦
pkwalify,kwalify(1).- other non-XML schema languages:
<http://rx.codesimply.com/>
and that's the whole page bestie!! πΈ this absolute icon of a manpage is perl v5.40.1, dated 2026-01-27, and it's the Kwalify(3pm) we know and love. go validate something and slay π
β¨π«Ά
π¦ where this page comes from
- ubuntu resolute: pkwalify 1.24-1build1 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- ubuntu stonking: pkwalify 1.24-1build1 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms